Php:the Big Picture

Source: Internet
Author: User
Tags closing tag

Before getting down-to-the business of writing some real PHP, I want-take aFew minutes to explain some basics. PHP needs to is processed by the webServer before the page can be viewed in a browser.So, as a rule, you need to store all pages inside the server root.In the most cases, this is a folder called Htdocs.although, it Sometimes called www, www root, or public HTML. there is cases were PHP files can be stored outside the server root for security reasons. But that's something you can learn about at the later stage . The server relies on the file name extension to know whether to process a page as PHP.

Unless you ' re hosting a company or server administrator tells you otherwise, alwaysUse . PHP. You can mix pages with the. html filename extension in the same site. But it's a good idea-to-use. php for all files, even if they don ' t contain PHP code. by doing so, you can add PHP code later without needing to change the URL. PHP code should is enclosed in PHP tags. The opening tag consist of an opening angle bracket, question Mark,and PHP. There ' s no space between any of the characters.

In some scripts, you'll find just the opening angle bracket followed by theQuestion mark, without the PHP. This is a shortened version.It works on a lot of servers, but isn ' t guaranteed to work everywhere.So, I recommend this should always use the full opening PHP tag.The closing tag is a question mark followed by a closing angle bracket. Now , in some cases you can omit the closing tag. But if there's any HTML or anything else on the Web page other than PHP code, the closing tag must always be there . If in doubt, I recommend always using a closing tag. PHP can look daunting if you start out.

But you ' ll quickly recognize the common features.Variables act as place holders for unknown or changing values.Arrays hold multiple values. Conditional statements to makedecisions and loops to perform repetitive tasks. Functions and objects perform preset tasks. (JS is also the case, do these languages have anything in common?). whenviewing PHP pages, it's important to remember, the PHP code must is processed by the Web server. If you've got into the habit of double-clicking HTML pages to view them locally, that's won ' t work with PHP.

What would happen is so you'll either just see the raw code or you'll bePrompted to download the file. So, it's important to remember theserver is Running. It may sound obvious, but it's easy to forget, particularly in the early stages. Should always view the page using a URL. So, in the most cases, this would be HTTP/local host, followed by wherever ' ve put the file. remember those Basic points, and you'll soon discover that PHP isn ' t all that difficult to learn and are great fun-to-use.

Php:the Big picture

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.