First stage PHP basics. Data type

Source: Internet
Author: User
Tags float double parse error php basics true true

A beginner of PHP's accompanying notes, record their growth!

A PHP base
1.php,web Program Development language, server-side scripting language
2.PHP Benefits
(1) PHP Code Open Source
(2) Support multiple Web servers (Apache,iis,nginx, etc.)
(3) Support multiple platforms (Windows,linux)
(4) Support multiple databases (mysql,sqlserver,oracle, etc.)
3. Install the PHP environment
(1) Web server (Apache)
(2) PHP engine
Rationale: If the client requests a page that is a. php page,
While the Web server cannot parse dynamic pages, you must
Please PHP engine to help the. PHP page to perform the static
Results are returned to the Web server and the Web server will be statically
The result of the configuration is returned to the client browser.
4.PHP syntax structure
(1) XML style (standard format)
<?php
...
?>
Description: If the PHP code is at the end of the document '?> '
can be omitted (recommended omitted)
(2) Short style
<?
...
?>
Description
Change the php.ini configuration file
Short_open_tag=off
Change to on to restart Apache server
To take effect
(Linux operation steps:
(a) su root
Password: ycty2016
(b) Editing the php.ini configuration file
Vi/etc/php.ini
(c)
Command Search mode
Search:/Keywords
Search down: N
Edit mode I
(d) back to command search mode ESC
: Wq Save and exit
(e) Restarting the Apache server
Service httpd Stop
Service httpd Start
Service httpd Restart Restart
)
(3) ASP style
<%
...
%>
Description: Change the php.ini configuration file
Asp_tags=off
Change to on to restart Apache server
To take effect

(4) Script style
<script language= "PHP" >
...
</script>

5.PHP document Structure (php+html)
(1) PHP code
(2) Xhtml
(3) Css
(4) Javascript
Description: PHP document structure can have multiple PHP syntax
Structure, and the PHP syntax structure can be put into
Anywhere, each sentence of PHP code with a semicolon
End.

6. Variables (Variable)
1. Variables: Information that has a name in memory and its value can be
Changes in the program's operation.
2. Declaring variables
$ variable name;
$ variable name = value;
3. Naming rules for variable names
(1) $ start, the variable name begins with a letter or an underscore,
followed by numbers, letters, underscores
(2) The variable name is forbidden to contain spaces, inclined to carry, reverse inclined to carry
and other special symbols
(3) Variable name as far as possible contain clear
(4) Variable name try to use hump style
For example: $userName $UserName
(5) Variable names are case-sensitive
Description: If the same variable name is repeated, the following value
Overwrite the previous value
7. Data types (8 primary data types and 4 pseudo-types)
7.1 8 Primary data types
(1) Scalar data type (store a single value)
A. Integral type (integer INT)
B. Floating-point type (float Double)
C. Boolean type (Boolean Bool)
D. Character type (String)
(2) Composite data type (store multiple values)
A. Arrays (array)
B. Objects (object)
(3) Special data types
A. Resources (Resource)
B.null
7.2 Integral type (integer INT)
(1) Decimal
(2) Binary 0b
(3) Octal 0
(4) Hex 0x
Description: The integer size is affected by the operating system
Can php_int_max view the maximum value
Overflow if the value of the variable exceeds the maximum value of the integer type
7.3 Floating-point type (float Double)
(1) Scientific counting method E E
2e3 = 2*10^3 =2000
2e-3 = 2/10^3 = 0.002
(2) Floating-point size is affected by the operating system
1.8e308
(3) floating-point type with approximate value in PHP
All do not compare to floating-point types
7.4 Boolean type (boolean bool)
Description: Only two values are true true,
False false False
7.5 Character type (String): characters must be enclosed in delimiters
(1) Delimiter
A. Single quotation mark (recommended)
B. Double quotation marks
C.heredoc (Custom delimiter)
D.nowdoc (Custom delimiter)
(2) difference between single and double quotation marks
A. Double quotes can parse variables and single quotes
Cannot parse variable
B. Double quotation marks can parse all escape characters,
and single quotes can only parse \ ' and \ \
(3) escape character (in source code in markup)
\ \ anti-skew carry
\ ' Single quotation mark
\ "Double quotation marks
\ r Enter
\ nthe line break
\ t Horizontal tab
\v Vertical Tab
(4) Single and double quotes in HTML entities and escaped
Use of characters
Description
A.W3C Specifies the special symbols that are seen in the browser
Must be implemented with HTML entities, which in PHP
must also be output with HTML entities
B. Single and double quotes in the source code in the browser,
Implemented in PHP with escape characters

(5) Use of {}
Principle: Double quote output variable, PHP engine can parse
The variable in double quotes will be valid as much as possible
string as the variable name, if you want to tell the PHP engine
To do so, enclose the variable name in {}.
Description
A. You can use {} to get a character or modify a variable
One character, numbering starting from 0
B. When the number is greater than the string length, fill it with a space
(6) HereDOC (Custom delimiter)
$ variable name =<<< delimiter name
...
Delimiter name
Description
A. When a large segment of code such as a large segment of XHTML is present
With Heredoc
B. End delimiter name must be at the beginning of the line,
Cannot have spaces
C.heredoc can parse variables and escape characters
(7) Nowdoc (Custom delimiter)
$ variable name =<<< ' delimiter name '
...
Delimiter name
Description
A. When a large segment of code such as a large segment of XHTML is present
With Nowdoc
B. End delimiter name must be at the beginning of the line,
Cannot have spaces
C.nowdoc cannot parse variables and escape characters
=======================================
(1) Echo: Output one or more strings to the browser

echo ' string ';
Echo ' String ', ' string ' ...;
Echo (' string '); only one string can be output
(2) Solve PHP Chinese garbled
Header (' Content-type:text/html;charset=utf-8 ');
Description: Header () cannot have other outputs in front of it

(3) Var_dump: Print output variable details

Var_dump ($var);
Var_dump ($var 1, $var 2,...);

(4) Error in PHP
A. Parse Error parsing errors
B. Warning warning Error
C. Notice Notification Error
D. Fatal fatal error

Description: PHP.ini configuration file
A. Display_error =off
On re-starting Apache server instead
B. Error_reporting=e_all (recommended)
error_reporting= E_all&~e_notice
(Show all errors except notification errors)






































First stage PHP basics. Data type

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.