How to compare php vesrion ?
echo version_compare(PHP_VERSION,’5.0.0′); if our php version is greater than ‘5.0.0’ will print 1. echo version_compare(PHP_VERSION,’7.0.0′); if our php version is greater than ‘7.0.0’ will print 1. so, if(version_compare(PHP_VERSION,’5.0.0′)>=0){ echo “php version is greater or equal to 5.0.0 ” }
How to execute a function in php after a specific amount of time?
How to call a function in PHP after 5 seconds in php ? sleep(timeinsecond); is used to make a delay in php. sleep(5); 5 second delay . Then we can call any function in php
How to check whether an email is valid or not in php ?
Using filter_var function , we can check whether an email is valid or not valid with FILTER_VALIDATE_EMAIL filter. if(filter_var(“sample@gmail.com”,FILTER_VALIDATE_EMAIL)) { echo “valid”; } else echo “not valid”;
How to split a url in php
How to split a website url in php? Using parse_url() function you can split the URL in php $url_str=parse_url(‘http://www.thehindu.com/news/national/highlights-from-prime-ministers-lok-sabha-speech-targeting-congress/article22678689.ece’); print_r($url_str); Answer will be : ( [scheme] => http [host] => www.thehindu.com [path] => /news/national/highlights-from-prime-ministers-lok-sabha-speech-targeting-congress/article22678689.ece )
How to get get the client IP address in PHP ?
For all the questions related to server, or current files, orĀ system using, you get the answer from a single php global variable: it is $_SERVER. just print_r($_SERVER) the variable you get all the details. How to get get the client IP address in PHP ? print_r($_SERVER[‘HTTP_CLIENT_IP’]); print_r($_SERVER[‘REMOTE_ADDR’]); print_r($_SERVER[‘HTTP_X_FORWARDED_FOR’]); How to get get the…