PHP Learning Notes (i)----Introduction to PHP and basic syntax

Source: Internet
Author: User
Tags php source code

 Php

I. Introduction of PHP

  PHP (foreign name: Php:hypertext Preprocessor, Chinese name: "Hypertext Preprocessor") is a common open source scripting language. Grammar absorbs the features of C, Java, and Perl,

Conducive to learning, widely used, mainly for the field of web development. PHP's unique syntax mixes the syntax of C, Java, Perl, and PHP's own creation. It can be faster than CGI or Perl,

Executes a Dynamic Web page. Dynamic pages made in PHP are compared to other programming languages, and PHP is embedded in the HTML (an application under the standard Universal Markup Language) document to execute,

Execution efficiency is much higher than CGI, which fully generates HTML markup; PHP can also execute post-compilation code that compiles to encrypt and optimize code runs, making code run faster.

Second, the characteristics of PHP 

Features of PHP include:

1. PHP's unique syntax mixes C, Java, Perl, and PHP's self-innovative syntax.

2. PHP can execute dynamic pages more quickly than CGI or perl--dynamic pages, compared to other programming languages,

PHP is to embed the program into the HTML document to execute, the execution efficiency than the full HTML markup generated CGI is much higher;

PHP has a very powerful function, all CGI features PHP can be implemented.

3. PHP supports almost all popular databases as well as the operating system.

4. The most important thing is that PHP can be used in C, C + + program extension!

Third, the advantages of PHP

Open Source Code

All of the PHP source code is actually available.

Free Sex

PHP itself is free and open source code compared to other technologies.

Quick Sex

The program develops fast, runs fast, and the technology itself learns fast. Embedded in HTML: Because PHP can be embedded in the HTML language, it is relative to other languages. Easy to edit, practical and more suitable for beginners.

Strong cross-platform capability

Since PHP is a server-side script that can run on Unix, LINUX, WINDOWS, Mac OS, Android and other platforms

High efficiency

PHP consumes a fairly small amount of system resources.

Image processing

Using PHP to create images dynamically, PHP image processing uses GD2 by default. It can also be configured to use image magick to process images.

Object oriented

In PHP4,PHP5, the object-oriented aspect has been greatly improved, and PHP can be used to develop large commercial programs.

Professional focus

PHP supports scripting languages and is the same Class C language.

Iv. basic syntax for PHP

  1. Language tag format for PHP

(1), Standard style:

<?php

PHP code body;

?>

Note: In a pure PHP script, it is not "?>", follow the specification and use standard style writing code.

(2), short style:

<?

PHP code body;

?>

(3), ASP style:

<%

PHP code body;

%>

2. PHP Comment Method

(1), single-line comment:

1 <? PHP 2 3 / / Single comment 4 //Echo Hello world;

(2), multi-line Comment:

1<?PHP2     3     //Multi-line comments4 5    /* 6 echo "Hello world! Hello world! Hello world! Hello world! ";7 echo "Hello world! Hello world! Hello world! Hello world! ";8 echo "Hello world! Hello world! Hello world! Hello world! ";9 echo "Hello world! Hello world! Hello world! Hello world! ";Ten    */    

3. PHP variable naming rules

(1), named definition: Do not start with a number, strictly case-sensitive, alphanumeric underline name, not the keyword name;

(2), naming method:

1. The variable name has the best meaning, the related variable content;

2. Use the Hump method name, that is, when the variable name or function name is connected by one or more words, and the structure

The first word begins with a lowercase letter, the first letter of the second word is capitalized or each

The initials of each word are capitalized, like the camel's hump.

PHP Learning Notes (i)----Introduction to PHP and basic syntax

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.