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.

Implementation of two kinds of file downloads in php

Implementation of two kinds of file downloads in php Language Notes PHP

1. Directly add a file link 🔒 Hidden content: Viewable after logging in <button> <a href= "http://localhost/down.zip" > Download File </button> 2. Pass parameters to search for and redirect to a download link: Passing parameters: <button> <a href...>
👁 136
mysqli in PHP

mysqli in PHP Language Notes PHP PHP collection PHP and mysql

The `mysqli_num_rows()` function is exclusively used with `SELECT` query methods, whereas the `mysqli_affected_rows()` function returns the number of rows affected by the previous SQL statement across the entire database; this function is primarily used with `INSERT`, `UPDATE`, and `DELETE` operations.
👁 146
Summary of PHP integer division and rounding methods

Summary of PHP integer division and rounding methods Language Notes PHP

Four commonly used methods for applying the `intval` integer conversion function in PHP: 1. Direct truncation – discards the fractional part and retains the integer: `intval()`; 2. Rounding – rounds the number to the nearest integer: `round()`; 3. Ceiling – rounds the number up by adding 1 if it has a fractional part: `ceil()`; 4. Floor – rounds the number down to the nearest integer: `floor()`. I. `intval` – Converts a variable to an integer type; if the argument is a string, it is automatically converted to 0. Example: `intval(3.14159);`...
👁 146
php generate random numbers/generate random strings

php generate random numbers/generate random strings Language Notes PHP

Apply MD5 encryption to the timestamp and extract a portion of it: <?php function token($length){ $str = md5(time()); $token = substr($str, 5, $length); return $token;} echo token(6);?>
👁 159
php function explode

php function explode Language Notes PHP

After retrieving the text content from the form's textarea input field, use the `explode(' rn', $str)对字符串内容进行分割, 发现rn,n,r都无法分割.使用PHP_EOL常量却正常分割成为数组.$arr = explode(PHP_EOL, $str);` function.
👁 132
PHP solve json

PHP solve json Language Notes PHP

Solution 1: Use the urlencode and urldecode methods to bypass the header transformation process (headers: 'Content-Type: application/json; charset=utf-8'); $arr = array 'lang' => urlencode 'I speak Chinese'...
👁 183
Three ways to reverse string in php

Three ways to reverse string in php Language Notes PHP

(For example, given the string "abcd", implement string reversal using PHP): 1. The first method utilizes PHP's built-in `strrev` function for easy implementation: `strrev($str);` 2. Alternatively, split the string into an array and then traverse and concatenate the characters: `function joinStrrev($str...)`
👁 169
PHP file() function

PHP file() function Language Notes PHP

Definition and usage: The `file()` function reads an entire file into an array. Similar to `file_get_contents()`, the difference is that `file()` returns the file as an array. Each element in the array represents a corresponding line from the file, including the newline character. If the operation fails, it returns `false`. Syntax: `file(path, include_path, context...)`
👁 160
PHP 5 String functions

PHP 5 String functions Language Notes PHP

PHP string functions are an integral part of PHP core. No installation is required to use these functions. Function Description addcslashes() Returns a string with a backslash added before the specified character. addslashes() returns a string with backslashes added before predefined characters. bin2hex() Converts a string of ASCII characters to a hexadecimal value. chop() deletes words…
👁 169
php and HTML refresh current page

php and HTML refresh current page Language Notes PHP

PHP and HTML refresh the current page, which will be used many times, so record it! 🔒 Hidden content: You can view echo after logging in "&lt;script language=JavaScript&gt; location.replace(location.href);&lt;/script&gt;"; echo 'The server is busy, please&lt…
👁 149
1 17 18 19 20 21 22