PHP: Hypertext Preprocessor is a general-purpose programming language originally designed for web development. It was originally created by Rasmus Lerdorf in 1994; the PHP reference implementation is now produced by The PHP Group.
Other topics associated
-
32bits simple hash function in PHP — PHP provides a simple function can hash in 32bits - hash( $algorithm, $key) - it will provide 8 bytes string as hash result.
-
Array of arguments passed to script in PHP — $argv is an array of arguments passed to script in PHP, so you can know the parameters when user run the script
-
Bob Jenkins' One-At-A-Time hashing algorithm in PHP — Bob Jenkins' One-At-A-Time hashing algorithm is simply known as jenkins_hash() providing 8 bytes long hash value.
-
Call PHP-based server URL without its extenstion (.php) — If you develop software based in PHP but you don't know to show its extension(.php) like http://foo.com/auth instead of http://foo.com/auth.php, you can make your PHP page work without its extension by adding ForceType application/x-httpd-php on .htaccess
-
Check CPU - is AMD or Intel? — In CentOS 7, CPU information is stored in /proc/cpuinfo, so you can implement to acquire CPU information in the system.
-
Check if user is root or sudo in php — posix_getuid() returns non-zero if user is root or sudo, so you can warn user to use an appropriate permission if required.
-
Checking XML element by preg_match — Below code shows how to check XML element by preg_match
-
Clearing a PHP value/array — Sometimes, you will need to reset variables, and unset() will help you to do it.
-
Count number of processes and do something in PHP — You can limit number of cron jobs, if you use PHP for DevOps software in CentOS 7, which can be easily implemented by checking process by shell_exec.
-
Delete one element in PHP array — The unset() function in PHP resets any variable. If unset() is called inside a user-defined function, it unsets the local variables. If a user wants to unset the global variable inside the function, then he/she has to use $GLOBALS array to do so. The unset() function has no return value.
-
Display an array as an HTML table with the index value in PHP — foreach($array as $key => $value) is useful when you need key and its value at the same time.
-
Display the result of a MySQL query in an HTML table — You can obtain the results of a MySQL server query using the mysqli extension.
-
Display the result of running python code by shell command (shell_exec) in PHP — I usually use shell_exec when I need to run python code. The benefit of shell_exec is returning the result as string, so I can use it for other purpose.
-
Downgrade PHP from version 7.3 to 7.2 on CentOS — You can downgrade PHP from version 7.3. to 7.2 by yum and yum-config-manager.
-
Easy Python Launcher based on PHP — You can run your python code easily based on your web browser if you have Apache+PHP server. Below code enable you to run your code by click