Skip to end of metadata
Go to start of metadata


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.

Below is the default coding template I use for PHP:

php coding template
<?php
/* Copyright <copyright owner> <home page URL> */
 
 	/**
 	 * @file <file name>
 	 * @brief <bried information> \n
 	 * @author <author information>
     */

?>


Example)

php remark example
<?php
/* Copyright Chun Kang <http://qsok.com> */
 
 	/**
 	 * @file /modules/api/register_user.php
 	 * @brief Registger user \n
 	 * @author Chun Kang (ck@qsok.com)
     */

?>


Regarding PHP common settings, please refer PHP configuration I commonly use


Other topics associated

  • Page:
    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.
  • Page:
    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.
  • Page:
    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
  • Page:
    Checking XML element by preg_match Below code shows how to check XML element by preg_match
  • Page:
    Clearing a PHP value/array — Sometimes, you will need to reset variables, and unset() will help you to do it.
  • Page:
    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.
  • Page:
    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.
  • Page:
    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.
  • Page:
    Facebook scalable architecture beyond LAMP — Facebook is known as using LAMP as their basic platform for their website. One of the outstanding things Facebook doing very well is that they have their own strategy/architecture based on LAMP. LAMP stands for Linux + Apache + MySQL + PHP that is entirely free and open sourced software, so they can compete with their competitors in competitive operation cost with high-avail-abilities. In person, I think their strategy is pretty much innovative and its status tells their strategy is on the right direction.
  • Page:
    Find files in PHP scandir( $path) returns the searched result in array. If you want to implement recursive scan for sub directories, you can implement it by checking filetype().
  • Page:
    Function as a part of parameter in PHP — PHP provides super easy feature can put a function as a part of function parameter. You can just put it like function exampleMethod( $customFunc).
  • Page:
    Get Client's IP Address in PHP — I had got client's IP address by $REMOTE_ADDR or $_SERVER['REMOTE_ADDR'], but it does not work on latest version of PHP.
  • Page:
    Get DB field name in PHP PDO from MySQL query result — PDO provides a method to get database field name (column name) from the query result.
  • Page:
    Get elements in GET, POST, COOKIE, SERVER as variable The extract() Function is an inbuilt function in PHP. The extract() function does array to variable conversion. That is it converts array keys into variable names and array values into variable value. In other words, we can say that the extract() function imports variables from an array to the symbol table.
  • Page:
    Get file extension in PHP — pathinfo() in PHP enables you to have file extension easily.

  • No labels