Question: Are PHP functions case sensitive?
Inbuilt function are not sensitive.
User defined functions are senstivie.
Case sensitive (both user defined and PHP defined)
- variables
- constants
- array keys
- class properties
- class constants
Case insensitive (both user defined and PHP defined)
- functions
- class constructors
- class methods
- keywords and constructs (if, else, null, foreach, echo etc.)
Question: How to return call by reference value from function?
Just use &(ampersand) before the function name.
For Example.
function &showData($data){ $data.=' New String'; return $data; }
Question: How to check a form is submited OR Not?
if($_SERVER['REQUEST_METHOD'] == 'POST'){ //form is submitted }
Question: How to remove all leading zeros from string?
echo ltrim('00000012', '0'); //12
Question: How to find HTTP Method?
$_SERVER['REQUEST_METHOD']It will return GET, HEAD, POST, PUT etc
Question: How to Serializing PHP object to JSON?
$userModel = new UserModel(); echo json_encode($userModel);//serialize data
Question: How to get current URL of web page?
echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
Question: How to add N number of days in an data?
echo date('Y-m-d', strtotime("+30 days"));
Question: How to get Yesterday date?
echo date("F j, Y", time() - 60 * 60 * 24); //November 1, 2016
Question: What's the maximum size for an int in PHP? The size of an integer is platform-dependent
Maximum value of about two billion for 32 bit system.
Question: How to remove all specific characters at the end of a string?
$string = 'Hello. * cool'; echo $string = str_replace(array('*', '.',' '), '', $string); //Remove * . and space [you can add more as you want]