A stick to learn PHP beginner introductory Tutorials _php Basics

Source: Internet
Author: User
Tags learn php php error save file

One stick learn PHP

System length of 32678 bytes, remove punctuation, you can also play 10,000 words, if full, it is not short.
In the spirit, abnormal simple, smooth in the end of the broad masses of impetuous mjj to browse the principle, I try to streamline the effective practical description of the way of learning PHP.

This article is suitable for audiences:
proficient in HTML, but no knowledge of dynamic languages such as PHP , but in the use of dedecms or Discuz and other PHP program people.
Of course, you also want to learn PHP interest. After all, even if it is easy to learn the motivation, interest is undoubtedly the best.
Not familiar with computer operation, absolute path, relative path and other things please go to Mars.

Prerequisite Preparation:
Attitude: Serious, careful, not impetuous.
Time: only two hours , but pay attention to two hours of full time. Do not take the time to do anything else, because in the study when a but interrupted, and then back to the inevitable yangaoshoudi suspicion, and I for the top PHP professional writer, can not be systematized teaching, Once interrupted look back to see this article will be worthless. So please prepare for two hours. I try to make it possible for you to have PHP in two hours.
Setting up the Environment:① Single Machine . ② for the novice to use the integrated environment, ③ I recommend the software: Apmserv download Address (PHP version 5.2.0)
In order to prevent a super new newcomer in the environment erected this piece of card, I first sent a apmserv set up the environment of the tutorial stickers. Click to view . Construction Operation area.

Pre-start FAQ

Q: I study hard after two hours can become a master?
A::tu: Less with me yy, " a stick to learn PHP" Purpose only in the simple learn php! can only let you two hours after the general understanding of PHP, have in-depth study of the Foundation. Please do not have illusions, down-to-earth, step by step to win. After reading, even if can not become a master, will be further to the master Michael.
Q: What editor do I need to use for something?
A: This teaching is only used Macromedia Dreamweaver 8 editor. The editor is not a must. The text can also make the webpage!
Q: You nonsense is not too much ...
A: Hungry, then start right away.
————————————————————————————————————–

============= Shameless split Line =============

Eat one:
One : iconic language.
There are The corresponding in PHP can be so yy, he has only a label <?php?> all things are bad in the position behind the PHP.
Line one: <?php
Line two: A section of PHP code
Line three:?>
All of these <?php can be replaced by the "php" ~ ~ ~
Do-it-Yourself projects:
DW New, dynamic page, PHP, code mode, delete all content, and then enter the <?php?> and ", and then enter, and before the deletion of keys several times, experience the Red maiden pleasure!" Just a few minutes have started to write PHP pull ~ Fierce, Master also ~

Two: the simplest output
Bad people may be in the above "a little PHP code" position hit something, and then save the open after a look, a blank and even wrong ...
Because PHP is certainly not HTML, he is the server language, the so-called server language is that you open to this page, and then the server side according to the rules to parse into HTML and then return to you to open. More than HTML, a server parsing process.
Try the following code:
?
Echo ' smiles and eats so handsome '
?>
Save file name is yy.php opened, such as prefix default of course, PHP, must be in support of PHP environment to open only effect. If you encounter problems here, check to see if the Apmserv is open and the location of the file you saved is in the Apmserv directory Www\htdocs Under. If all is right, then look at the browser address is not http://127.0.0.1: Port/yy.php

Three: the most common mistake
Then modify the code as follows:
?
echo ' smiles and eats so handsome '
Echo ' is so handsome '
?>
Do you find errors when you open them? This is the most common, most idiotic and most common PHP error in history.
PHP is parse-by-line, pay attention to the "line" understanding. At the end of each line you need to add ";" Is the letter L to the right one.
I am also very puzzling, even more annoyed is no error correction function, a wrong can not open all, but the error will show the wrong line.

Four: the most important concept
The previous code is added as " ; " After opening, you will find that the effect of "a smile to eat good handsome ah really good handsome ah" stick together.
Right-click the source file and you will find that the original source file is the same. What about it?
PHP is a language that can be inserted into HTML, which means he can qj html ...
Theoretically , no matter how long?> can be inserted into the HTML ... Copy the following experience ...

Five: the most important application
Here, if you haven't moved your hands, please move your hands, all of the above is only a few minutes, but there is an important experience process.
Seriously do people will find that PHP so learn to have a fart use? So now ... I can't tell you what the use is, and then here's the variable.
I try to use less terminology and try to be popular, but the word variable doesn't find a substitute. But very well understood, and then look.
?
$chifan = "123er";
Echo $chifan;
?>
Save open, the display of content is 123er, so familiar with HTML is very easy to modify the code "" between the 123er can modify the display content it!
No mistake, and theoretically modify two Chifan, as long as they remain the same, can also be displayed.
There are only two lines, the first line is to define the variable Chifan value is 123er, the second row is the display variable Chifan. It's as simple as that.
It's easy to learn how to define variables and display them!

Dinner Two:
AfterEat aSimple and interesting and lively learning, do you think PHP is actually not difficult? But are you also starting to worry that PHP is useless?
This section describes the conceptual nature of PHP in detail.
It is obvious that there is no previous vivid, this paragraph is not necessary, if just want to understand and do not intend to learn completely can skip this paragraph. <>
R/>PHP Functions:What is a function? for example, Y=2X is a function, then, as long as you know x can be derived from the corresponding Y. PHP's powerful function library is one of its main features, such as MySQL-specific functions, then only need a database name username password can be free and simple connection to the database.
PHP Manual: A booklet that records PHP syntax and functions, because not everyone can remember every grammar of each function. So most people will need to consult the manual when they use it. It's the meaning of a simple metaphor, such as the Y=2X function, you do not know there is this function you have to be counted as x+x, But if you know that there's a y=2x function, you just need to call the function y, and then enter X to get the result. For the PHP manual, it is recommended that you take the time to see it again and again, but remember what it is. Maybe x+x you can write it yourself, but more complicated you don't have to write it, Even if it's a little hard to write, the more troublesome the problem is, the more obvious and necessary it is to invoke the ready-made function.
Write their own functions, function and significance of such a powerful, but always have their own unique requirements of the function, the function can write their own, good use of functions can achieve a multiplier effect ... So much nonsense is to understand the function, the visible function is how important!
The last recommendation or understanding of the analogy, a few practical functions such as time call function, IP address acquisition function, can be found in the manual, simply call the function to display the results can easily get the time and the IP address you want to customize. (Do not understand I have no solution)
face the object and face process: Please Baidu or GG, feel more and more digress ... From the simple subject.
syntax Details:
such as:;? echo "haha"?>. What is the difference between the echo ' haha '?>?""And"And the difference between the Full-width and the Half-width. "" () () and How to display "" These variables to define things such as headaches!... I have a headache when I think of it. It must be a headache to see this coming.
There is no difference between the full-width and half-width, and the function is the same. It's perfect.
How to display the symbol of the grammar is not difficult, only need to add a/can before the corresponding symbol. But it looks awkward.
The difference between a double primer and a single citation is that the two-quote parse the variable, and the single citation is the direct display.
?
$MJJ = "haha";
Echo $MJJ;
echo "<br>";
echo "This is $MJJ";
echo "<br>";
Echo ' This is $MJJ ';
?>
The following three are a small complement to the common syntax. then start the internship.
constants: Define
<?php
define ("Page_title", "MJJ page");
Define ("Page_body", "MJJ is a wooden chicken");
?>
<title><?php Echo Page_title?></title>
<body>
<?php Echo Page_body?>
</body>

simpler output <?=?>
As the above title sentence can be replaced by:
<title><?= page_title?></title>
page invoke require and include
All 2 of them call other pages, and PHP is translated line-by-row, but require is a priority call, and include is translated when you read this line.
How to use the call, is the great art of the door. (Afraid of error require can use require_once only call the page once) format is as follows:
require_once './include/286.php ';
include ' mjj.php ';
Build yourself a 286.php or mjj.php to play it. can be written as txt but must conform to the PHP syntax. Used as PHP.

Three meals:
instance: one- line URL Jump code

Copy Content to Clipboard

Code:

<? $url=$_GET["url"];header("Location:"."http://".$url);?>

If save for aaa.php, can realize aaa.php?url=www.baidu.com jump to Baidu effect.
This simple call to the default $_get variable. and PHP default jump location:
(more default variables are in the manual)
instance upgrades: increasing the IF loop

Copy Content to Clipboard

Code:

<?
$url=$_GET["url"];
if (strlen($url >= '3')){
header("Location:"."http://".$url);
}
?>
<title>URL转向页</title>
<body>
<form id="url" name="url" method="get" action="#">
<label>http://
<input name="url" type="text" value="" />
</label>
<input type="submit" name="Submit" value="提交" />
</form>
</body>

So much has not been talked about the cycle, as is the most difficult content of this tutorial (to foil a stick to learn how simple ~)
This upgrade code is very simple, you can make this jump page can also open, when get down URL address is greater than 3 o'clock to jump.

After the completion of the study:
If you are inspired to learn PHP and feel that you are really getting started (and looking again without getting started), then there are two advanced methods.
The robust can first read through the PHP manual, and then start looking for a message, blog, BBS (order, can be text and then MySQL) to start a step-by-step production of the example.
Passionate type, you can start looking for an example to start to follow the example step-by-step, some feel lack after the PHP manual added. There are too many instances on the web.
improve the stage: understand php4,php5,php6 changes and differences. The main focus on the current popular PHP program for research. (This also needs to adapt to an editor, if it is possible to better understand a framework, the outdated forum has published framework, code area see.) Open source PHP program will bring you a new experience, understand later do not come at least also change to understand.
advanced Stage: I do not have the qualifications to introduce. I hope we can become masters together.
Finally, I wish all the friends who are interested in PHP can become masters!

————————————-Split Line —————————
Finally completed, does not exclude the vulnerability, this article total spents 4 hours + 3 hours. Hope to be able to help the friend who needs.

<div style= "Background-color: #606096; height:6px; font-size:0px; " ></div>
<div style= "height:24px;padding:3px 10px 0px 0px;text-align:right; Background: #F1F1F1; " >

?
echo ' smiles and eats well handsome ';
Echo ' is really very handsome ';
?>

</div></div>

</body>
Note that the color that DW helps to display is useful.
Friendship ads: This effect for the laggards forum at the top of the code, there is a need to widely imitate the use.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.