Determine PHP script Invocation: CLI or by the Web Server
In most cases you can distinguish if a PHP script was invoked from the command line (or Cron) or by the web server, using php_sapi_name(). php_sapi_name() will return cli on…
In most cases you can distinguish if a PHP script was invoked from the command line (or Cron) or by the web server, using php_sapi_name(). php_sapi_name() will return cli on…
Sometimes you need to replace accented characters with non accented, for example when you want to perform an accent insensitive search. A solution could be the following function: <?php /**…
PHP DateTime class, available with PHP versions greater than 5.2 is very powerful. As an example, it ts very easy to check if a string represents a valid date or…
Use of include is very common in PHP. include will parse a file and display the result. But, how to store the result in a variable for later use? In…
To get current datetime (now) with PHP you can use date with any PHP version, or better datetime class with PHP >= 5.2 Various date format expressions are available here.…