The first day of learning php in ten days

Source: Internet
Author: User

I used to learn ASP for ten days and ASP. NET for ten days. Now I want to write another PHP, which is quite complete. I will not talk about the PHP debugging method here. Many articles have been introduced and there are many different combinations. I am currently using Apache web server and my SQL as WEB server and database, in the php-4.3.3 environment to do the program. Of course, it is essential to simply build and access the PHPMYADMIN database.

As for form design, I don't want to talk much about it here. I have already introduced it in "ten days learning ASP.

The following describes the PHP syntax.

1. embedding method:

PHP can be <? Php or <?, End symbol?>, Of course, you can also specify it yourself.

2. reference file:

There are two methods to reference files: require and include.
The use of require is as follows: require ("MyRequireFile. php ");. This function is usually placed at the beginning of the PHP program. Before the PHP program is executed, it will first read the file specified by require to make it a part of the PHP program webpage. This method can also be used to introduce common functions into webpages.

Include usage methods such as include ("mydomaindefile. php ");. This function is generally placed in the Process of process control. The PHP program webpage reads the include file. In this way, you can simplify the process during program execution.

3. annotation method:

<? Php
Echo "This is the first example. \ N "; // note the C ++ syntax in this example
/* This example uses multiple rows
Annotation Method */
Echo "this is the second example. \ N ";

Echo "is the third example. \ N "; # This example uses the UNIX Shell syntax to annotate
?>

4. Variable type:

$ Mystring = "I Am a string ";
$ NewLine = "NewLine \ n ";
$ Int1 = 38;
$ Float1 = 1.732;
$ Float2 = 1.4E + 2;
$ MyArray1 = array ("child", "ugly", "Yin", "Mao ");

Two problems are raised here. First, the PHP variable starts with $, and the second PHP statement ends with;, which may be unsuitable by ASP programmers. These two omissions are also the cause of many program errors.

5. Operator number:

Mathematical operations: Symbolic Meaning
+ Addition operation
-Subtraction
* Multiplication
/Division
% Obtain the remainder
++ Accumulate
-- Decrease

String operation:

There is only one operator number, which is an English ending. It can be used to connect strings and convert them into new merged strings. Similar &
<?

$ A = "PHP 4 ";
$ B = "powerful ";
Echo $ a. $ B;
?>
Two problems are also raised here. The output statement in PHP is echo, and the second is similar to the <% = variable %> in ASP, which can be used in PHP. <? = Variable? >.

Logical operation:

Symbolic Meaning
<Less
> Greater
<= Less than or equal
> = Greater than or equal
= Equal
! = Not equal
& And (And)
And (And)
| Or (Or)
Or (Or)
Xor exclusive or (Xor)
! No (Not)

Let's talk about process control today. Let's talk about process control tomorrow.

 

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.