Technology

Unique and Convenient PHP Usage Examples

Discover unique and convenient PHP usage examples for enhancing your coding efficiency and optimization.

Sangrak

I plan to keep adding to this list.

Handy Tips

Conditional Assignment

// Example 1
$limit = ($_GET['limit']?$_GET['limit']:20);

// Example 2
$limit = ($_GET['limit']?:20);
// Example 1
if (!$foo) $foo = 5; 

// Example 2
$foo or $foo = 5;

// Example 3
$foo || $foo = 5;
// Example 1
if ($foo) func();

// Example 2
$foo && func();

More on this topic