PHP

PHP

Zend Server | Snippets | Laravel |

Pages in the group PHP:


http://www.phpro.org/tutorials/Validating-User-Input.html

http://www.chipmunkninja.com/Program-Execution-in-PHP%3A-exec-m@


O'Reilly Web Programming Library

http://docstore.mik.ua/orelly/webprog/


PHP Shorthand:

found here http://davidwalsh.name/javascript-shorthand-if-else-examples

Basic True / False Declaration

$is_admin = ($user['permissions'] == 'admin' ? true : false);

Conditional Welcome Message

echo 'Welcome '.($user['is_logged_in'] ? $user['first_name'] : 'Guest').'!';

Conditional Items Message

echo 'Your cart contains '.$num_items.' item'.($num_items != 1 ? 's' : '').'.';

Conditional Error Reporting Level

error_reporting($WEBSITE_IS_LIVE ? 0 : E_STRICT);

Conditional Basepath

echo '<base href="http'.($PAGE_IS_SECURE ? 's' : '').'://mydomain.com" />';

Nested PHP Shorthand

echo 'Your score is:  '.($score > 10 ? ($age > 10 ? 'Average' : 'Exceptional') : ($age > 10 ? 'Horrible' : 'Average') );

Leap Year Check

$is_leap_year = ((($year % 4) == 0) && ((($year % 100) != 0) || (($year %400) == 0)));

Conditional PHP Redirect

header('Location: '.($valid_login ? '/members/index.php' : 'login.php?errors=1')); exit();

Issus with Character Encoding and MySQL

http://akrabat.com/php/utf8-php-and-mysql/ http://ireallylikesushi.com/blog/2009/05/13/mediatemple-mysql-connection-character-encoding/ http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html


MVC

Here is an slideshare presentation on FuelPHP http://www.slideshare.net/chriscubos/fuelphp-a-php-hmvc-framework-by-silicongulfcom

PmWiki

pmwiki.org

Blix theme adapted by David Gilbert, powered by PmWiki