Hongmu Notes
Home Language Notes PHP

PHP

PHP (Hypertext Preprocessor) is a server-side scripting language particularly suited for web development and can be embedded within HTML. Its syntax is derived from the C language, incorporating features from languages such as Java and Perl to develop its own distinctive grammar; it has also been continuously refined and enhanced based on the strengths of these languages—for example, leveraging Java's object-oriented programming capabilities.

Detailed description of php $_SERVER

Detailed description of php $_SERVER Language Notes PHP

$_SERVER['SCRIPT_NAME'] //当前脚本的路径dirname($_SERVER['SCRIPT_NAME'] // dirname() returns the directory portion of a path; $_SERVER['SCRIPT_FILENAME'] // The absolute path of the currently executing script...
👁 151
PHP dirname() function and

PHP dirname() function and Language Notes PHP

The code is as follows: `echo __FILE__; // Retrieves the absolute path of the current file; Output: D:\www\test.php` `echo "<br />";echo dirname(__FILE__); // Retrieves the absolute directory containing the current file; Output: D:\www\` `echo...`
👁 157
How to use the rename function in php to rename files

How to use the rename function in php to rename files Language Notes PHP

// Check whether the file already exists: if (!file_exists($dbname)){ if(file_exists($ab_new_name)) {echo "A file with the same name '{$ab_new_name}' already exists.";} else {echo "...";}
👁 143
What are the differences between die(), exit(), and return in php?

What are the differences between die(), exit(), and return in php? Language Notes PHP

`die()` stops the program execution and does not output any content; `return` returns a value; `die()` stops the program only when an error occurs; `exit()` stops the program immediately without executing any subsequent code; `exit()` can optionally display output; `return` merely returns a value without executing any subsequent code; `exit(0)` terminates the program normally; `exit(1)` terminates the program due to an abnormal condition...
👁 169
PHP modifies the contents of the php file

PHP modifies the contents of the php file Language Notes PHP

tweaking this PHP code a bit... (sweat) – There are four incoming parameters: the file name, the variable to match, the value, and the data type. The fourth parameter can be omitted... (sharp) // Configuration update function: function update_config($file, $ini, $value, $type = "string") {if (!file_exist...
👁 98
php gzcompress() and gzuncompress() functions implement string compression

php gzcompress() and gzuncompress() functions implement string compression Language Notes PHP

:(Comical) When we talk about compression, we might think of file compression; however, strings can also be compressed. PHP provides the `gzcompress()` and `gzuncompress()` functions: `$string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nu...";`
👁 110
PHP glob() function

PHP glob() function Language Notes PHP

Definition and Usage: The `glob()` function returns the filenames or directory names that match a specified pattern. This function returns an array containing the matched filenames or directory names; if an error occurs, it returns `false`. Syntax: `glob(pattern, flags)`. Parameters: - `pattern`: Required. Specifies the search pattern. - `flags`: Optional. Specifies special options. Example: Example 1: `<?php print_r(glob('*.php'));`
👁 128
Example of how to obtain the top-level domain name in the URL address using PHP

Example of how to obtain the top-level domain name in the URL address using PHP Language Notes PHP

This article demonstrates an example of how to use PHP to extract the top-level domain (TLD) from a URL. We share this code for your reference; the implementation is as follows: The `parse_url()` function returns the host portion of a URL, which may contain multiple-level domains (e.g., `mp.weixin.qq.com`). When creating a domain blacklist, it is necessary to identify the top-level domain. If you find any shortcomings in this code, please leave a comment to point them out – thank you! <?php /** * @Author: Di...
👁 152
PHP iconv encoding conversion in file

PHP iconv encoding conversion in file Language Notes PHP

Convert UTF-8 to GBK $data = iconv(&quot;utf-8&quot;,&quot;GBK//IGNORE&quot;,$data); Convert GBK to UTF-8 $data = iconv(&quot;GBK&quot;,&quot;utf-8//IGNORE&quot;,$data); IG...
👁 176
Implementation of php caching function

Implementation of php caching function Language Notes PHP

Different websites require varying caching functionalities; some only need to cache the requested GET parameters, while others require caching the entire URL. Below is a commonly used caching code snippet that has already been written. Caching code: `<?php // Cache storage directory define('CACHE_ROOT', dirname(__FILE__). '/');`
👁 209
1 16 17 18 19 20 22