PHP+MySQL basic knowledge supplement_PHP tutorial
1. 10 sentences
1. Don’t rely on the register_global=ON environment. From the day you first know how to configure the PHP operating environment and don’t even understand how register_global’s ON/OFF will affect you, you should bravely set it to OFF.
2. Before writing a program, look at how to use error_reporting.
3. It’s okay to ask yourself if you don’t understand, but you need to check the manual before that.
4. Of course, you need to understand the user manual. When you can't find the answer in the manual, you should consider searching on the Internet.
5. After you have just learned php+mysql, don’t clamor to write a forum, write XXX. Understand that just because you have just learned to write Chinese characters does not mean that you are capable of writing poetry.
6. When learning web programming, you should first get to know your friend html.
7. After you have some ability, try to answer questions from novices. Don’t be complacent when you see that you understand something but others don’t. It’s even worse to leave without saying, “It’s simple, that’s a basic thing.”
8. Thinking is a good habit. If you don’t write, it means you have nothing.
9. After writing a program, if you feel satisfied with it, read it again after a week. Maybe you will think it should be changed
10. Take a look at other people’s programs when you have time, find out other people’s shortcomings or advantages, and weigh them yourself.
2. Everyone gets what they need
1. Be good at using "references", which can directly affect the efficiency of the program.
2. Being good at using ternary operators can make the program more streamlined and efficient.
For example:
PHP code:
if ($data[$i][nickname]){
$nickname =$data[$i][nickname];
}
else{
$nickname =$data[$i][ip];
}
Can be written as:
PHP code:
$nickname = $data[$i][nickname] ? $data[$i][nickname] : $data[$i][ip];
3. Good at organizing if...else...loops
For example:
PHP code:
$ext_name = strtolower(str_replace(".", "", strrchr($upfilename, ".")));
if (!empty($type))
{
if (!strpos($type, $ext_name))
{
echo "Please upload the file of $type form.";
exit();
}
}
You should write the above code like this:
PHP code:
$ext_name = strtolower(str_replace(".", "", strrchr($upfilename, ".")));
if (!($type===) && strpos($type, $ext_name)===false)
{
echo "Please upload the file of $type form.";
exit();
}
4. Try to make your code as clear as possible. If it is written like this, it will be a headache:
PHP code:
$foo=$_post["foo"];
$username=$_post["user"];
$group=$_POST["group"];
if ($group=="wheel")
{
$username=$username."wheel";
}
The same code, so it is more comfortable to read:
PHP code:
$foo = $_post["foo"];
$username = $_post["username"];
$group = $_POST["group"];
if ($group=="wheel")
{
$username = $username."wheel";
}
Of course, after you have a certain foundation, you should write like this:
PHP code:
$foo = &$_POST[foo];
$username = $_POST["group"]!=wheel ? $_POST["username"] : $_POST["username"].wheel;
5. Write standardized mysql statements.
Field and table names are quoted with "`" to avoid the impact of reserved words.
If you see a SQL query like the following, it will give you a headache:
PHP code:
$query="select `flash_comment`.`content` , `flash_comment`.`nickname` , `flash_comment`.`date` , `flash_comment`.`ip` , `product`.`p_name` , `sgflash `.`fid` from `flash_comment` left join `product` on ( `flash_comment`.`p_no` = `product`.`p_no` ) left join `sgflash` on ( `product`.`p_name` = `sgflash` .`f_name` ) where `flash_comment`.`p_no` != order by `flash_comment`.`date`";
The same query is much clearer when written like this:
PHP code:
$query = "SELECT `flash_comment`.`content` , `flash_comment`.`nickname` , `flash_comment`.`date` , `flash_comment`.`ip` , `product`.`p_name` , `sgflash `.`fid` FROM `flash_comment` LEFT JOIN `product` ON ( `flash_comment`.`p_no` = `product`.`p_no` ) LEFT JOIN `sgflash` ON ( `product`.`p_name` = `sgflash` .`f_name` ) WHERE `flash_comment`.`p_no` != ORDER BY `flash_comment`.`date`";

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



Windows Recovery Environment (WinRE) is an environment used to repair Windows operating system errors. After entering WinRE, you can perform system restore, factory reset, uninstall updates, etc. If you are unable to boot into WinRE, this article will guide you through fixes to resolve the issue. Unable to boot into the Windows Recovery Environment If you cannot boot into the Windows Recovery Environment, use the fixes provided below: Check the status of the Windows Recovery Environment Use other methods to enter the Windows Recovery Environment Did you accidentally delete the Windows Recovery Partition? Perform an in-place upgrade or clean installation of Windows below, we have explained all these fixes in detail. 1] Check Wi

In this article, we will learn about the differences between Python and Anaconda. What is Python? Python is an open source language that places great emphasis on making the code easy to read and understand by indenting lines and providing whitespace. Python's flexibility and ease of use make it ideal for a variety of applications, including but not limited to scientific computing, artificial intelligence, and data science, as well as creating and developing online applications. When Python is tested, it is immediately translated into machine language because it is an interpreted language. Some languages, such as C++, require compilation to be understood. Proficiency in Python is an important advantage because it is very easy to understand, develop, execute and read. This makes Python

How to set up keyboard startup on Gigabyte's motherboard. First, if it needs to support keyboard startup, it must be a PS2 keyboard! ! The setting steps are as follows: Step 1: Press Del or F2 to enter the BIOS after booting, and go to the Advanced (Advanced) mode of the BIOS. Ordinary motherboards enter the EZ (Easy) mode of the motherboard by default. You need to press F7 to switch to the Advanced mode. ROG series motherboards enter the BIOS by default. Advanced mode (we use Simplified Chinese to demonstrate) Step 2: Select to - [Advanced] - [Advanced Power Management (APM)] Step 3: Find the option [Wake up by PS2 keyboard] Step 4: This option The default is Disabled. After pulling down, you can see three different setting options, namely press [space bar] to turn on the computer, press group

1. Processor When choosing a computer configuration, the processor is one of the most important components. For playing games like CS, the performance of the processor directly affects the smoothness and response speed of the game. It is recommended to choose Intel Core i5 or i7 series processors because they have powerful multi-core processing capabilities and high frequencies, and can easily cope with the high requirements of CS. 2. Graphics card Graphics card is one of the important factors in game performance. For shooting games such as CS, the performance of the graphics card directly affects the clarity and smoothness of the game screen. It is recommended to choose NVIDIA GeForce GTX series or AMD Radeon RX series graphics cards. They have excellent graphics processing capabilities and high frame rate output, and can provide a better gaming experience. 3. Memory power

SPDIFOUT connection line sequence on the motherboard. Recently, I encountered a problem regarding the wiring sequence of the wires. I checked online. Some information says that 1, 2, and 4 correspond to out, +5V, and ground; while other information says that 1, 2, and 4 correspond to out, ground, and +5V. The best way is to check your motherboard manual. If you can't find the manual, you can use a multimeter to measure it. Find the ground first, then you can determine the order of the rest of the wiring. How to connect motherboard VDG wiring When connecting the VDG wiring of the motherboard, you need to plug one end of the VGA cable into the VGA interface of the monitor and the other end into the VGA interface of the computer's graphics card. Please be careful not to plug it into the motherboard's VGA port. Once connected, you can

Glodon Software is a software company focusing on the field of building informatization. Its products are widely used in all aspects of architectural design, construction, and operation. Due to the complex functions and large data volume of Glodon software, it requires high computer configuration. This article will elaborate on the computer configuration recommendations of Glodon Software from many aspects to help readers choose a suitable computer configuration processor. Glodon Software requires a large amount of data calculation and processing when performing architectural design, simulation and other operations. Therefore, the requirements for the processor are higher. It is recommended to choose a multi-core, high-frequency processor, such as Intel i7 series or AMD Ryzen series. These processors have strong computing power and multi-thread processing capabilities, and can better meet the needs of Glodon software. Memory Memory is affecting computing

LINUX is a widely used operating system that is highly customizable and stable. CentOS is a free and open source operating system built on the Red Hat Enterprise Linux (RHEL) source code. It is widely used in servers and desktop environments. In CentOS Installing software packages on CentOS is one of the common tasks in daily use. This article will introduce how to install gnuplot on CentOS and solve the problem of missing dependencies of Sunflower software. Gnuplot is a powerful drawing tool that can generate various types of charts, including two-dimensional and three-dimensional data visualization. To install gnuplot on CentOS, you can follow the steps below: 1.

Does ECharts need to rely on jQuery? Detailed interpretation requires specific code examples. ECharts is an excellent data visualization library that provides a rich range of chart types and interactive functions and is widely used in web development. When using ECharts, many people will have a question: Does ECharts need to rely on jQuery? This article will explain this in detail and give specific code examples. First, to be clear, ECharts itself does not rely on jQuery;
