Tutorial by Examples

echo and print are language constructs, not functions. This means that they don't require parentheses around the argument like a function does (although one can always add parentheses around almost any PHP expression and thus echo("test") won't do any harm either). They output the string r...
print_r() - Outputting Arrays and Objects for debugging print_r will output a human readable format of an array or object. You may have a variable that is an array or object. Trying to output it with an echo will throw the error: Notice: Array to string conversion. You can instead use the print_r...
printf will output a formatted string using placeholders sprintf will return the formatted string $name = 'Jeff'; // The `%s` tells PHP to expect a string // ↓ `%s` is replaced by ↓ printf("Hello %s, How's it going?", $name); #> Hello Jeff, How's it going? // Ins...
You can use concatenation to join strings "end to end" while outputting them (with echo or print for example). You can concatenate variables using a . (period/dot). // String variable $name = 'Joel'; // Concatenate multiple strings (3 in this example) into one and echo it once done. ...
On 32-bits systems, integers larger than PHP_INT_MAX are automatically converted to float. Outputting these as integer values (i.e. non-scientific notation) can be done with printf, using the float representation, as illustrated below: foreach ([1, 2, 3, 4, 5, 6, 9, 12] as $p) { $i = pow(1024,...
Array ( [0] => Array ( [id] => 13 [category_id] => 7 [name] => Leaving Of Liverpool [description] => Leaving Of Liverpool [price] => 1.00 [virtual] => 1 [active] =...

Page 1 of 1