Latest posts


Detect CLI (Command Line Interface) using PHP
The main focus of CLI SAPI is for developing shell applications with PHP. However, you may want to create some applications which could be run, at the same time, using CLI and another SAPI (eg: web server). To detect CLI, you can use this function: Let’s say we want to create a simple application that […]
Things to check before upgrading to PHP 8 (I). Using count() on null (uncountable) parameter produces a fatal error.
Things to check before upgrading to PHP 8 (I). Using count() on null (uncountable) parameter produces a fatal error.
MySQL: How to change root password? Debian, Ubuntu, Fedora, CentOS
## 1. FIND ROOT USERNAME The root username is always `root`. ## 2. HOW TO CHANGE DEFAULT ROOT PASSWORD Connect to your server, using command line (terminal), then run: **Stop MySQL:** If you are using Ubuntu or Debian: sudo /etc/init.d/mysql stop For CentOS, Fedora, and RHEL: sudo /etc/init.d/mysqld stop **Start MySQL in safe mode:** sudo […]
How to show page execution time in PHP (One line)
There are two methods of displaying the page generation time in PHP. **Old PHP versions can do this as below:** $time_start = microtime(true); // Write your code here… $time_end = microtime(true); $gen_time = $time_end – $time_start; echo “This page has been generated in: {$gen_time} seconds.”; **As of PHP 5.4.0 you can simply measure page generation […]
How to install V8JS for PHP on Ubuntu
V8Js is a PHP extension for Google’s V8 Javascript engine. The extension allows you to execute Javascript code in a secure sandbox from PHP. The executed code can be restricted using a time limit and/or memory limit. This provides the possibility to execute untrusted code with confidence. How to install? 1. Connect to your server’s […]
Automatically change font size to fit parent’s width (JavaScript)
## 1. The script function fontFitWidth(el, settings = {}) { el.style.whiteSpace = “nowrap”; el.style.fontSize = (settings.min | 9) + “px”; fontSize = (settings.min | 9); while(el.scrollWidth
Search on our website