Some knowledge about PHP_PHP tutorial
1. How to configure PhpMyAdmin2.9
The configuration files of many tutorials on the Internet are for the bottom version of PhpMyAdmin. At the beginning, I didn’t even know where to put the 2.9 configuration file?
The relative address of the configuration file is: config.sample.inc.php (not this libraries/config.default.inc.php)
2. Let phpMyAdmin use the password to log in
Set the following parameters in config.inc.php:
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['blowfish_secret'] = '123456' ; // Set a non-empty string at will
$cfg['DefaultLang'] = 'zh'; // Display Chinese by default, optional
3. No PHP extension setting mbstring was found, and The current system seems to be using a wide character set. There is no mbstring....Modify the php.ini file extension=php_mbsting.dll and it will take effect after restarting!
4. When PHP reads Chinese characters from the MySQL database, all question marks are displayed?
Before querying the database, use mysql_query("set names 'gb2312'");
5. Use PHP to output static pages
There are two types
One One is to use template technology, and the other is to use ob series functions. Both methods look similar, but in fact they are different.
The first one: using templates
There are currently a lot of PHP templates, including the powerful smarty and the simple and easy-to-use smarttemplate.
Each of their templates has a function to get the output content.
The way we generate static pages is to use this function.
The advantage of using this method is that the code is clearer and more readable.
Here I use smarty as an example to illustrate how to generate a static page
require('smarty/Smarty.class.php');
$t = new Smarty;
$t->assign("title","Hello World!");
$content = $t->fetch("templates/index.htm");
/ /The fetch() here is the function to get the output content. Now the $content variable is the content to be displayed
$fp = fopen("archives/2005/05/19/0001.html", "w" );
fwrite($fp, $content);
fclose($fp);
?>
Second method: Use the ob series of functions
The functions used here are mainly ob_start(), ob_end_flush(), ob_get_content(),
where ob_start() means to open the browser buffer,
After opening the buffer, all No non-file header information from the PHP program will be sent,
but will be saved in the internal buffer until you use ob_end_flush().
The most important function here is ob_get_contents(),
The function of this function is to get the contents of the buffer, which is equivalent to the fetch() above,
for the same reason. Code:
ob_start();
echo "Hello World!";
$content = ob_get_contents();//Get all the content output by the php page
$fp = fopen("0001.html", "w");
fwrite($fp, $content);
fclose($fp);
?>
6. PHP Detailed explanation of language reading database
The function of this code is:
Connect to a mysql server with url address localhost and port 3306. The account number of the mysql server is "root" and the password is "9999". There is a database ok on the mysql server, and there is a table abc in the database. Table abc has two columns in total. The column names are "id" and "name". Read out all the data in abc.
$dbh = @mysql_connect("localhost:3306","root","9999");
/* Define variables dbh, mysql_connect( ) function means to connect to the mysql database, "@" means to block error reports */
if(!$dbh){die("error");}
/* die( ) function means to send the string in the brackets to the browser and interrupt the PHP program (Script). The parameters in brackets are the string to be sent.*/
@mysql_select_db("ok", $dbh);
/* Select a database in the mysql server, the database name selected here is ok */
$q = "Select * FROM abc";
/* Define variable q, "Select * FROM abc" is a SQL statement, which means reading the data in table abc */
?>
$rs = mysql_query($q, $dbh);
/* Define variable rs, function mysql_query() Meaning: Send the query string for MySQL to perform related processing or execution. Since PHP is executed from right to left, the value of rs is the value returned by the server after running the mysql_query() function */
if (!$rs){die("Valid result!");}
echo "
ID | Name|
$row[0]< ;/td> | $row[1] |
?>
$rs = mysql_query($q, $dbh);
while($row = mysql_fetch_object($rs)) echo "$row->id $row->name
";
/* id and name can Change position */
?>
$rs = mysql_query($q, $dbh);
while ($row = mysql_fetch_array($rs)) echo "$row[id] $row[name]
";
/* id and name can change positions */
?>
< ?
@mysql_close($dbh);
/* Close the connection to the mysql database */
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
