Never had a dream come true from Phpnet Getting Started tutorial

Source: Internet
Author: User
Tags new set
PHP is a tool for creating dynamic Web pages. A Web page that embeds PHP code is like an ordinary HTML file, and you can edit it with any editor you like. The object described in this tutorial is PHP 3.0.
What do I need? In this tutorial, we assume that your server already supports PHP, and that all files are in. php3 as the extension. On most servers, this is the default extension for PHP files, and you can check with your administrator. If your server supports PHP, that's enough. It's easy to build your PHP file and put it on your server, and the server will handle it smartly. This does not require compiling anything, nor does it require any additional tools to be installed. You can think of it this way: the PHP file is a plain HTML file that joins a whole new set of clever tags.
The color of the code above your first PHP code just gives you a visual help, making it easier to understand the different parts of PHP's tags and expressions. Note that this is not like a CGI program and does not require executable permissions. You can think of PHP files as HTML files containing a special set of tags that can do a lot of things that interest you.
This program is very simple and you do not have to create a Web page specifically for this purpose. What it does is show: Hello world.
If you tried this code, but it didn't output anything, the problem might be that your server doesn't support PHP. Please ask your administrator to confirm.
The focus of the precedent is to introduce you to PHP tags. With The label ends. As shown in the example, in the HTML file you are free to enter and exit PHP mode.
Something useful for us to do something more meaningful. If we're going to check what the user's browser is, you can check the user agent string that the browser sends to the Web server. This information is stored in a variable named $http_user_agnet, and it is easy to display the value of the variable with the following statement:
If the user is using Internet Explorer, the result may be: mozilla/4.0 (compatible; MSIE 4.0; Windows 98) In fact, the user's browser also passes a lot of other content. You can get a complete list of these variables using the following code:
Put this code into a file, say info.php3, upload it to your server, open it with a browser, and you'll see a lot of surprises. You can place multiple PHP statements in a set of PHP tags, or you can use a block of code to do more. For example: If we want to check if the browser is MSIE, we can use the following code:
{
echo "You are using Internet Explorer.
";
}
?> here we will introduce some new things. The first is the "if" statement. If you are familiar with the basic syntax of C, then it is easy to read this piece of code. If unfamiliar, it is recommended to find some relevant books for reference. PHP retains the simple syntax of C, eliminating the difficulty of controlling strings and memory handling in C.
Second, we call a function: Strstr (). Strstr () is a PHP built-in function for finding another string in a string, in which case we look for "MSIE" in the variable $http_user_agent, and if the font string is found, then the function returns True, that is, the inverse.
Let's look at how to get into and out of PHP mode, even in the middle of a block of PHP code:
if (Strstr ($HTTP _user_agent, "MSIE")) {
?>
You is using Internet Explorer
}else{
?>
You is not using Internet Explorer
}?>
Instead of using the Echo statement to output the result, use the method of outputting the HTML code directly out of PHP mode. It is very important to not break the logical integrity of the PHP code, and the result of running this code may be:
You is using Internet Explorer
Another powerful place to work with forms PHP is to work with forms in HTML files. To understand this basic concept, the elements of all HTML file forms are automatically routed to the target page with the same name. This may seem a bit difficult to understand, and we'll illustrate this in the following example:

This form contains only the necessary HTML tags and is not complete. When the user fills out the form and presses the "Submit" button, the file action.php3 is called. If you say this file contains the following code:
Hi . You are Years old.
The effect is obvious because the variables $name and $age are automatically set by PHP.
More of it? This tutorial may be expanded, so far.
For other tutorials please refer to:
Webmonkey
Devshed
Phptidbits
Phpbuilder.com

The above describes the never had a dream come true from phpnet introductory tutorial, including never had a dream come true content, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    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.