#php

Adds a new item or items in front of an array.

array_unshift($awesome_array, "new item");
copy
#php#header

Changes document header and returns document data in JSON format.

header('Content-Type: application/json');
copy
#php

Run the following command to get installed PHP version.

php -v
copy
#php

Print value to the view.

$day = "Monday"
print $day;
copy
#php

Print value in a readable format. Useful when fetching large objects or arrays.

print_r($someObject);
copy
#php

Push a new item or items at the end of an array.

array_push($awesome_array, "new item");
copy
#php#conditional

Ternary operator evaluates first parameter followed by two values. First value is returned when the condition is true otherwise the second value is returned.

// Condition ? True : False

$hour = 14;
($hour <= 12) ? "Morning" : "Afternoon";
copy
#php

Return all the data about a variable in a structured format.

var_dump($your_variable);
copy
Sitemap Git repository