PHP Note 1

Source: Internet
Author: User
Tags learn php

<?php 8 data Types 4 kinds of scalar shaping Boolean type character type two compound types Array (array) object (object) two special types resource (Resource) null (NULL)

Single quote echo ' direct output variable name '
echo ' $a '; Output $ A
Double quote echo "Direct output variable"
echo "$a"; Output $ A variable

One kanji represents three strings
First scenario: Double quotation marks are embedded in single quotes,
Second scenario: Embedding single quotation marks in double quotation marks
The third scenario: using the escape character "\
$str _string1 = ' A Q: "Where did you learn PHP? "‘;
$str _string2 = "B did not hesitate to answer: ' Of course, XXX!" ‘";
$str _string3 = ' A Q: \ ' Can you tell me the URL? \‘‘;
$str _string4 = "B answer: \" Www.xxxx.com\ "";

$a = fopen ("Open File Root", "R");//Open File

$b = fgets ($a);//Read the contents of the file

$c = fclose ($a);//Close file

Use define (constant name, constant value, [case sensitivity])
Define ("MOOS", "xx", true);
Define ("MOOS", "xx"); default constant name is case-sensitive
Echo Moos;

Example
<?php
Define ("PI", 3.14);
$r = 3;
echo "area is:". (pi* $r * $r). " <br/> ";
echo "Perimeter is:". (2*pi* $r). " <br/> ";
?>

Operator
$a = 10;
$b = + + $a; First Gaga: After adding a value of 1, assign to variable B
Echo $b;
echo "<br/>";

$a = 10;
$b = $a ++;//, assign a value of 10 to variable B and add 1 yourself
Echo $b;
echo "<br/>";

$a = 10;
$a + +; The value of variable a increases from 1
echo $a;
Point Connector
echo $a. " + ". $b." =". ($a + $b);//

PHP Note 1

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.