1.不要依赖register_global=ON的环境,从你刚懂得配置php运行环境甚至尚不明白register_global的ON/OFF会对自己有什么影响的那天起,就应该勇敢地把它设为OFF.
2.写程序前看看怎么用error_reporting.
3.不懂就问本身没错,但你需要在那之前查查手册。
4.当然,你需要懂得使用手册。手册上找不到答案的时候,应该考虑下网络上的搜索引擎。
5.刚学会php+mysql之后,不要叫嚷着要写论坛,要写XXX。要明白,刚学会写汉字并不表示你有能力写诗。
6.在学web编程的时候,你应该先去认识html这个朋友。
7.有点能力后,试着回答新手的问题,不要看到自己懂的而别人不懂就沾沾自喜,扔下一名“简单,那是基本的东西”就走更要不得。
8.思考是一个好习惯,不动手去写就等于空想,什么也没有。
9.写好一段程序,如果觉得很满意,一周后再看一遍,也许你会认为它应该有所改变
10.有空多看看别人的程序,找出他人的不足或优点,自己掂量。
二. 各取所需
1.善于使用“引用”,它能直接影响到程序的效率。
2.善于用三元运算子,可以让程式较精简有效率。
比如:
<font size="2"><font face="Verdana">PHP代码:</font><hr></font><code><font color="#000000"> <font color="#0000bb"><br></font><font color="#007700">if (</font><font color="#0000bb">$data</font><font color="#007700">[</font><font color="#0000bb">$i</font><font color="#007700">][</font><font color="#dd0000">'nickname'</font><font color="#007700">]) <br>{ <br> </font><font color="#0000bb">$nickname </font><font color="#007700">= </font><font color="#0000bb">$data</font><font color="#007700">[</font><font color="#0000bb">$i</font><font color="#007700">][</font><font color="#dd0000">'nickname'</font><font color="#007700">]; <br>} <br>else <br>{ <br> </font><font color="#0000bb">$nickname </font><font color="#007700">= </font><font color="#0000bb">$data</font><font color="#007700">[</font><font color="#0000bb">$i</font><font color="#007700">][</font><font color="#dd0000">'ip'</font><font color="#007700">]; <br>}<br></font><font color="#0000bb"></font> </font> </code><hr>
可以写成:
<font size="2"><font face="verdana,arial,helvetica">PHP代码:</font><hr></font><code><font color="#000000"> <font color="#0000bb"><br>$nickname </font><font color="#007700">= </font><font color="#0000bb">$data</font><font color="#007700">[</font><font color="#0000bb">$i</font><font color="#007700">][</font><font color="#dd0000">'nickname'</font><font color="#007700">] ? </font><font color="#0000bb">$data</font><font color="#007700">[</font><font color="#0000bb">$i</font><font color="#007700">][</font><font color="#dd0000">'nickname'</font><font color="#007700">] : </font><font color="#0000bb">$data</font><font color="#007700">[</font><font color="#0000bb">$i</font><font color="#007700">][</font><font color="#dd0000">'ip'</font><font color="#007700">];<br></font><font color="#0000bb"></font> </font> </code><hr>
3.善于组织if...else...回圈
比如:
<font size="2"><font face="verdana,arial,helvetica">PHP代码:</font><hr></font><code><font color="#000000"> <font color="#0000bb"><br>$ext_name </font><font color="#007700">= </font><font color="#0000bb">strtolower</font><font color="#007700">(</font><font color="#0000bb">str_replace</font><font color="#007700">(</font><font color="#dd0000">"."</font><font color="#007700">, </font><font color="#dd0000">""</font><font color="#007700">, </font><font color="#0000bb">strrchr</font><font color="#007700">(</font><font color="#0000bb">$upfilename</font><font color="#007700">, </font><font color="#dd0000">"."</font><font color="#007700">))); <br>if (!empty(</font><font color="#0000bb">$type</font><font color="#007700">)) <br>{ <br> if (!</font><font color="#0000bb">strpos</font><font color="#007700">(</font><font color="#0000bb">$type</font><font color="#007700">, </font><font color="#0000bb">$ext_name</font><font color="#007700">)) <br> { <br> echo </font><font color="#dd0000">"Please upload the file of $type form."</font><font color="#007700">; <br> exit(); <br> } <br>}<br></font><font color="#0000bb"></font> </font> </code><hr>
上面的代码你应该写成这样:
<font size="2"><font face="verdana,arial,helvetica">PHP代码:</font><hr></font><code><font color="#000000"> <font color="#0000bb"><br>$ext_name </font><font color="#007700">= </font><font color="#0000bb">strtolower</font><font color="#007700">(</font><font color="#0000bb">str_replace</font><font color="#007700">(</font><font color="#dd0000">"."</font><font color="#007700">, </font><font color="#dd0000">""</font><font color="#007700">, </font><font color="#0000bb">strrchr</font><font color="#007700">(</font><font color="#0000bb">$upfilename</font><font color="#007700">, </font><font color="#dd0000">"."</font><font color="#007700">))); <br>if (!(</font><font color="#0000bb">$type</font><font color="#007700">===</font><font color="#dd0000">''</font><font color="#007700">) && </font><font color="#0000bb">strpos</font><font color="#007700">(</font><font color="#0000bb">$type</font><font color="#007700">, </font><font color="#0000bb">$ext_name</font><font color="#007700">)===</font><font color="#0000bb">false</font><font color="#007700">) <br>{ <br> echo </font><font color="#dd0000">"Please upload the file of $type form."</font><font color="#007700">; <br> exit(); <br>}<br></font><font color="#0000bb"></font> </font> </code><hr>
4.尽量让你的代码清淅些
如果写成这样,是比较让人头痛的:
<font size="2"><font face="verdana,arial,helvetica">PHP代码:</font><hr></font><code><font color="#000000"> <font color="#0000bb"><br>$foo</font><font color="#007700">=</font><font color="#0000bb">$_post</font><font color="#007700">[</font><font color="#dd0000">"foo"</font><font color="#007700">]; <br> </font><font color="#0000bb">$username</font><font color="#007700">=</font><font color="#0000bb">$_post</font><font color="#007700">[</font><font color="#dd0000">"user"</font><font color="#007700">]; <br></font><font color="#0000bb">$group</font><font color="#007700">=</font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"group"</font><font color="#007700">]; <br>if (</font><font color="#0000bb">$group</font><font color="#007700">==</font><font color="#dd0000">"wheel"</font><font color="#007700">){ <br></font><font color="#0000bb">$username</font><font color="#007700">=</font><font color="#0000bb">$username</font><font color="#007700">.</font><font color="#dd0000">"wheel"</font><font color="#007700">; <br>}<br></font><font color="#0000bb"></font> </font> </code><hr>
同样的代码,这样就比较让人看得舒服了:
<font size="2"><font face="verdana,arial,helvetica">PHP代码:</font><hr></font><code><font color="#000000"> <font color="#0000bb"><br>$foo </font><font color="#007700">= </font><font color="#0000bb">$_post</font><font color="#007700">[</font><font color="#dd0000">"foo"</font><font color="#007700">]; <br></font><font color="#0000bb">$username </font><font color="#007700">= </font><font color="#0000bb">$_post</font><font color="#007700">[</font><font color="#dd0000">"username"</font><font color="#007700">]; <br></font><font color="#0000bb">$group </font><font color="#007700">= </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"group"</font><font color="#007700">]; <br>if (</font><font color="#0000bb">$group</font><font color="#007700">==</font><font color="#dd0000">"wheel"</font><font color="#007700">) <br>{ <br> </font><font color="#0000bb">$username </font><font color="#007700">= </font><font color="#0000bb">$username</font><font color="#007700">.</font><font color="#dd0000">"wheel"</font><font color="#007700">; <br>}<br></font><font color="#0000bb"></font> </font> </code><hr>
当然,有一定基础后,你应该要写成这样:
<font size="2"><font face="verdana,arial,helvetica">PHP代码:</font><hr></font><code><font color="#000000"> <font color="#0000bb"><br>$foo </font><font color="#007700">= &</font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">'foo'</font><font color="#007700">]; <br></font><font color="#0000bb">$username </font><font color="#007700">= </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"group"</font><font color="#007700">]!=</font><font color="#dd0000">'wheel' </font><font color="#007700">? </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"username"</font><font color="#007700">] : </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"username"</font><font color="#007700">].</font><font color="#dd0000">'wheel'</font><font color="#007700">;<br></font><font color="#0000bb"></font> </font> </code><hr>
5.编写规范的mysql 语句。
字段和表名用"`"引起来,避免保留字的影响。
如果看到下面这样的一个sql query,会让人比较头痛:
<font size="2"><font face="verdana,arial,helvetica">PHP代码:</font><hr></font><code><font color="#000000"> <font color="#0000bb"><br>$query</font><font color="#007700">=</font><font color="#dd0000">"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`"</font><font color="#007700">;<br></font><font color="#0000bb"></font> </font> </code><hr>
同样的一个query,写成这样就令人看得明白得多了:
<font size="2"><font face="verdana,arial,helvetica">PHP代码:</font><hr></font><code><font color="#000000"> <font color="#0000bb"><br>$query </font><font color="#007700">= </font><font color="#dd0000">"SELECT `flash_comment`.`content` , `flash_comment`.`nickname` , `flash_comment`.`date` , `flash_comment`.`ip` , `product`.`p_name` , `sgflash`.`fid` <br> FROM `flash_comment` <br> LEFT JOIN `product` ON ( `flash_comment`.`p_no` = `product`.`p_no` ) <br> LEFT JOIN `sgflash` ON ( `product`.`p_name` = `sgflash`.`f_name` ) <br> WHERE `flash_comment`.`p_no` != '' <br> ORDER BY `flash_comment`.`date`"</font><font color="#007700">;<br></font><font color="#0000bb"></font> </font> </code><hr>
//

Die Hauptaufgabe von MySQL in Webanwendungen besteht darin, Daten zu speichern und zu verwalten. 1.Mysql verarbeitet effizient Benutzerinformationen, Produktkataloge, Transaktionsunterlagen und andere Daten. 2. Durch die SQL -Abfrage können Entwickler Informationen aus der Datenbank extrahieren, um dynamische Inhalte zu generieren. 3.Mysql arbeitet basierend auf dem Client-Server-Modell, um eine akzeptable Abfragegeschwindigkeit sicherzustellen.

Zu den Schritten zum Erstellen einer MySQL -Datenbank gehören: 1. Erstellen einer Datenbank und Tabelle, 2. Daten einfügen, und 3. Durchführen von Abfragen. Verwenden Sie zunächst die Anweisungen für erstellte und creatEtable, um die Datenbank und Tabelle zu erstellen, und verwenden Sie dann die Anweisung InsertInto, um die Daten einzulegen, und verwenden Sie schließlich die Auswahlanweisung, um die Daten abzufragen.

MySQL ist für Anfänger geeignet, da es einfach zu bedienen und leistungsfähig ist. 1.Mysql ist eine relationale Datenbank und verwendet SQL für CRUD -Operationen. 2. Es ist einfach zu installieren und erfordert, dass das Stammbenutzerkennwort konfiguriert wird. 3.. Verwenden Sie Einfügen, Aktualisieren, Löschen und Wählen Sie, um Datenvorgänge auszuführen. 4. OrderBy, wo und Join kann für komplexe Abfragen verwendet werden. 5. Debugging erfordert die Überprüfung der Syntax und verwenden Sie Erklärungen zur Analyse der Abfrage. 6. Die Optimierungsvorschläge umfassen die Verwendung von Indizes, die Auswahl des richtigen Datentyps und der guten Programmiergewohnheiten.

MySQL ist für Anfänger geeignet, weil: 1) Einfach zu installieren und konfigurieren, 2) Rich Learning Resources, 3) Intuitive SQL -Syntax, 4) leistungsstarke Toolunterstützung. Anfänger müssen jedoch Herausforderungen wie Datenbankdesign, Abfrageoptimierung, Sicherheitsmanagement und Datensicherung überwinden.

Ja, sqlisaprogrammingLuagespezialisierteForDatamanagement.1) Es ist dieklarativ, fokussierte Waagewhattoachieveratherthanhow.2)

Säureattribute umfassen Atomizität, Konsistenz, Isolation und Haltbarkeit und sind der Eckpfeiler des Datenbankdesigns. 1. Atomizität stellt sicher, dass die Transaktion entweder vollständig erfolgreich oder vollständig gescheitert ist. 2. Konsistenz stellt sicher, dass die Datenbank vor und nach einer Transaktion konsistent bleibt. 3. Isolation stellt sicher, dass sich Transaktionen nicht stören. 4. Persistenz stellt sicher, dass Daten nach der Transaktionsuntersuchung dauerhaft gespeichert werden.

MySQL ist nicht nur ein Datenbankverwaltungssystem (DBMS), sondern auch eng mit Programmiersprachen zusammen. 1) Als DBMS wird MySQL verwendet, um Daten zu speichern, zu organisieren und abzurufen und Indizes zu optimieren, können die Abfrageleistung verbessern. 2) Kombinieren Sie SQL mit Programmiersprachen, eingebettet in Python, und unter Verwendung von ORM -Tools wie SQLalchemy kann die Operationen vereinfachen. 3) Die Leistungsoptimierung umfasst Indexierung, Abfrage, Caching, Bibliothek und Tabellenabteilung und Transaktionsmanagement.

MySQL verwendet SQL -Befehle, um Daten zu verwalten. 1. Grundlegende Befehle umfassen Auswahl, Einfügen, Aktualisieren und Löschen. 2. Die erweiterte Verwendung umfasst die Funktionen, Unterabfragen und Aggregate. 3. Häufige Fehler sind Syntax-, Logik- und Leistungsprobleme. 4. Die Optimierungstipps umfassen die Verwendung von Indizes, die Vermeidung von Auswahl* und die Verwendung von Limit.


Heiße KI -Werkzeuge

Undresser.AI Undress
KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover
Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool
Ausziehbilder kostenlos

Clothoff.io
KI-Kleiderentferner

AI Hentai Generator
Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

Heiße Werkzeuge

SecLists
SecLists ist der ultimative Begleiter für Sicherheitstester. Dabei handelt es sich um eine Sammlung verschiedener Arten von Listen, die häufig bei Sicherheitsbewertungen verwendet werden, an einem Ort. SecLists trägt dazu bei, Sicherheitstests effizienter und produktiver zu gestalten, indem es bequem alle Listen bereitstellt, die ein Sicherheitstester benötigen könnte. Zu den Listentypen gehören Benutzernamen, Passwörter, URLs, Fuzzing-Payloads, Muster für vertrauliche Daten, Web-Shells und mehr. Der Tester kann dieses Repository einfach auf einen neuen Testcomputer übertragen und hat dann Zugriff auf alle Arten von Listen, die er benötigt.

PHPStorm Mac-Version
Das neueste (2018.2.1) professionelle, integrierte PHP-Entwicklungstool

DVWA
Damn Vulnerable Web App (DVWA) ist eine PHP/MySQL-Webanwendung, die sehr anfällig ist. Seine Hauptziele bestehen darin, Sicherheitsexperten dabei zu helfen, ihre Fähigkeiten und Tools in einem rechtlichen Umfeld zu testen, Webentwicklern dabei zu helfen, den Prozess der Sicherung von Webanwendungen besser zu verstehen, und Lehrern/Schülern dabei zu helfen, in einer Unterrichtsumgebung Webanwendungen zu lehren/lernen Sicherheit. Das Ziel von DVWA besteht darin, einige der häufigsten Web-Schwachstellen über eine einfache und unkomplizierte Benutzeroberfläche mit unterschiedlichen Schwierigkeitsgraden zu üben. Bitte beachten Sie, dass diese Software

Dreamweaver Mac
Visuelle Webentwicklungstools

Dreamweaver CS6
Visuelle Webentwicklungstools