PHP: Basic syntax _ PHP Tutorial

Source: Internet
Author: User
PHP: Basic syntax. Why learning PHP? I have been learning about android application development some time ago. as I learned more deeply, I gradually built an image processing system on the android platform. But why should I learn PHP soon?
I have been learning about android application development some time ago. as I learned more deeply, I gradually built an image processing system on the android platform. However, I soon discovered an important problem. Android operating systems generally run on mobile phone tablets and other devices with relatively limited hardware resources. Image processing requires a lot of matrix operations. Obviously, handheld configuration is difficult to meet such requirements. I saw some Image processing systems based on the android platform a few days ago. Among them, a C/S image processing system proposed by the EE368 lab of Stanford University aroused great interest. The system process is as follows:

[]


That is to say: although our handheld configuration resources are limited, we can send images and other information to remote servers for processing, then, send the processed information to our mobile phone. PHP plays an important role in it. As a result, I started learning PHP. The following is my summary of PHP syntax: (I have learned C/C ++/JAVA/HTML/MATLAB/ANDROID, etc. Therefore, PHP and C are similar, this is not an example)

PHP basic syntax example (1)

1. variable name

$ Abc = 1; $ _ abc = 12.5; $ _ ABC2TR = TURE; (must begin with $)

2. data type

Boolean is interpreted as true or false.

$ Bo = TRUE; $ bo = FALSE;

Integer)

$ Bo = 1; $ bo =-12;

Float (float type, also as "double") is interpreted as decimal type

$ BR = 1.001; $ BR = 3.1415926;

String (string)

$ Bo = "this string or EN Word ";

(Point "." is used to add strings.)

Array)

$ Bo = array (1, 2, 4); $ bo = array ("A" => 1, "B" => 2 );

3. output statement

Output statement: echo

4. condition statement if usage

(Same as C) else if; else

5. example of switch in conditional statements

(Same as C) case and break

6. example of loop statement for and whie usage

(Same as C) break

7. array definition and use example

Definition: Use array

$ Arr = array (3,5, 7,9, 6 );

$ Arr = array ("id" => 2, "title" => 3); // similar to the struct in C

Use: square brackets

$ Arr1 = array (3,5, 7,9, 6 );

$ Arr2 = array ("id" => 2, "title" => "hello array! ");

Echo $ arr1 [0]; // output 3

Echo"
"; // Line feed

Echo $ arr2 ['title']; // output helloarray!

$ Arr2 ['title'] = "Hi, Nanjing! "; // Assign a value

Echo"
"; // Line feed

Echo $ arr2 ['title']; // output Hi, Nanjing!

?>

8. function declaration and call example

Declaration: function keyword

Function name_fun (var1, var2 ,...) {

Return var1 + var2;

}

Call

Var3 = name_fun (var1, var2 ,...);

Example:

Function _ 11 number (){

For ($ I = 1; I I <100; $ I ++)

{

If ($ I % 11 = 0 ){

Echo $ I ."
";

}

}

}

_ 11 number ();

Output 1 ~ A multiple of 11 within 100.

Why? I have been learning about android application development some time ago. as I learned more deeply, I gradually built an image processing system on the android platform. But soon I will...

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.