PHP and Mysqlweb Application Development core Technology part 1th PHP Basics-1 start to understand PHP

Source: Internet
Author: User
Tags array expression integer php and php basics php code php script variable
1.1 First PHP
Copy CodeThe code is as follows:
<title>my-A-PHP program</title>
<body>
<?php
echo "Hello everybody!";
?>
</body>

Attach: Use of phpinfo () function
1.2 Input PHP Script
1.2.1 Mark PHP Code paragraph
1.2.2 Statements and comments
/* */
//
#
#
1.2.3 PHP and HTML blends
1.3 How to store data
1.4 Enter the basic data type of PHP
1.4.1 numbers: (int) and floating-point number (float)) octal must precede the number with 0 (0), and hexadecimal indicates that the number must precede 0x.
Note: 1 Floating-point number operations, only approximate values are taken
2 5/2=2.5 want to take the integer with round () function
1.4.2 String
Single quotation mark: ' To enclose a single quote in a string, simply precede it with a backslash.
The easiest way to define a string is to surround it with single quotes (punctuation marks).
To output a single quote, precede it with a backslash (\). To output a backslash before the single quote or at the end of the string, enter two (\)
Note that if you add a backslash before any other character, the backslash will be output directly.
Double quote ""
Escaped characters escape character meaning
\ n-line wrap (LF or 0x0A in ASCII)
\ r Carriage return (CR or 0x0D () in ASCII)
\ t Horizontal tab (HT or 0x09 (9) in ASCII)
\v Vertical tab (VT or 0x0b (one) in ASCII) (since PHP 5.2.5)
\f page Break (FF or 0x0C () in ASCII) (since PHP 5.2.5)
\ reverse Slash
\$ Dollar Dollar mark
\ "Double Quotes
\[0-7]{1,3} A string that conforms to the order of the expression is a octal character
\x[0-9a-fa-f]{1,2} A string that conforms to the order of the expression is a hexadecimal character
1.5 Some in very useful functions
1.5.1 NL2BR: Inserts an HTML newline character for each new line (\ n) of the string
Copy CodeThe code is as follows:
<?php
echo nl2br ("foo isn ' t\n bar");
?>

1.5.2 var_dump: View type and variable values
1.5.3 Print_r: Returns the result to a string rather than outputting the result to the output stream. This user-interface-friendly output is particularly useful for objects and arrays
Print_r () displays information that is easy to understand about a variable. If a string, integer, or float is given, the variable value itself is printed.
If you give an array, the keys and elements will be displayed in a certain format. object is similar to an array.
1.5.4 Var_export: It's similar to Var_dump, except that its output is actually a valid PHP code representation of the data value provided
Copy CodeThe code is as follows:
<?php
$arr =array (1,2,3,4);
Var_exprot ($arr);
?>


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.