Front-end understanding of the brief PHP

Source: Internet
Author: User
Tags alphanumeric characters

Understanding PHP

PHP is an embedded language in HTML:

Using <?php?> to represent php delimiters, the statements written in this symbol are all PHP statements.

haha, today I bought a <?php echo 1+2+3;?>s I'm so happy!

PHP cannot be dragged directly into the browser locally because php must be running environment

Building the development environment

One-click installation package Phpnow

Http://www.onlinedown.net/soft/60958.htm

There are:

Apache

PHP Interpretation engine

Mysql

Language Core Overview Writing position

The written label is written in

<?php?>

No nesting! Can appear in any position!

PHP page extension must be . PHP, if it is . html , then it will be considered static page, do not parse.

Output Statement

PHP requires that all statements be semicolon-delimited. If you do not add a serious error, you will be an error, the following statement is not run.

The output statement in PHP is the current location of the page, not the console.

echo "XXXX";

ECHO is the output statement in PHP

Like what:

<?php echo 1+2*3;?>

Echo can also be used as a function to write the contents of the output in parentheses:

<?php Echo (1+2*3);?>

echo default does not wrap, if you want to wrap, you use . As a hyphen stitching the label.

Variable

The variable starts with the $ sign, followed by the name of the variable

Variable names must begin with a letter or underscore

Variable names cannot start with a number

variable names can contain only alphanumeric characters and underscores ( A-Z,0-9 and _)

variable names are case sensitive ($y and $Y are two different variables)

variables in PHP are also weakly variable types, no need to define what type, and what type to pass.

1<? PHP2        $a = 5; 3        $b = "AAA"; 4        $ctrue;        echo$a . "<br/>"; 7        echo$b . "<br/>"; 8        echo$c . "<br/>";    ? >

the scope of PHP is amazing.

PHP also does not have block-level scopes,if, for does not produce scopes.

function has scope limitations. A global variable, within a function, is not recognized by default. If you want to know a global variable inside a function, write the global keyword inside the function:

1    <?  PHP2        $a =;        function Fun  () {5            global$a; 6            echo$a; 7        }        (); Ten    ?>

operator

and JS the same, is not the same character, hyphen is .

Array
1<? PHP2    $aarray("East", "South", "West", "North", "Middle"); 3    echo$a[0];? >

The Echo statement cannot output the full picture of an array, you must use the print_r function.

$a Array ("East", "South", "West", "North", "Middle"); Print_r ($a);

The array length is to be used with the count () function:

echo count ($a);

Statement

the same as JS.

There are also if statements,if... Else , for , while , Do ... while , Switch all the same.

function

function Declaration Header elevation is JS -specific,PHP must first define the function, and then call the function.

function only () a method of invocation.

The function's argument, return value, and JS is the same.

Front-end understanding of the brief PHP

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.