Simple PHP methods and variables

Source: Internet
Author: User
View code <? PHP
// Print, Echo Functions
Print "This is my first Program <Br> ";
$ Word = "This is my second Program <br> ";
Print $ Word ;
Echo "3rd programs <br> ";

//Printf
Printf("% '* 10.2f", 456.7 );
Echo"<Br> ";
Printf("% B", 8 );
Echo"<Br> ";

//Sprintf
$ Content= "Script language ";
$ App= "Web ";
$ Formatted=Sprintf("<H4> PHP is widely used in Embedded % A, especially suitable for % s development. </H4> ",$ Content,$ App);
Echo $ Formatted;

// print_r
echo "
";
$ name = array (" Zhang San "," Li Si "," Wang Wu ", "sat");
print_r ($ name );

// is is_bool a Boolean integer, whether is_int is an integer, whether is_float is float, and whether the string Escape Character "\"
echo "
";
echo "
";
$ I = 10;
If ( is_int ( $ I )) {
echo "I is an integer ";
}< br> else {
echo " I is not an integer ";
}< br> echo "
";
echo "
";

//Heredoc text output heredoc_mark is randomly named, followed by ";"
$ Doc= <Heredoc_mark
Hello! <Br>
Happy Birthday! <Br>
Heredoc_mark;

Echo $ Doc;

// is_object is an object type with a lag, whether is_resource is a resource type, whether is_null is null, unset clear variable assignment
echo "
";
$ I = 0; /// it is not a null type. The following is a null type: 1. the value is null. 2. no new variable is assigned. 3.
If ( is_null (k k ) {
echo " this is a null variable ";
}< br> else {
echo " This is not a null variable ";
}

// forced conversion of data types, it is not recommended to use automatic conversion. It is not clear enough.
$ Val = 11.78;
$ Val = (INT) $ Val ;
echo $ Val ;

//Functions related to data types
/*
* GetType (): return the Data Type of the specified variable.
* Settype (): You can set a variable to a specified type.
* Is_float (): determines if it is a floating point number.
* Is_array (): determines whether it is an array.
* Is_string (): determines whether it is a string.
* Is_integer (): determines whether it is an integer.
* Is_null (): determines whether it is null.
* Is_resource (): determines whether it is a resource type.
* Is_numeric (): determines whether it is a numerical value.
* Is_scalar (): determines whether the title type is used. The so-called "title type" refers to the type that contains only one item of information, such as Boolean, integer, floating point, and numeric, while array, object, and Other types include multiple items of information, therefore, it does not belong to the title type.
 */
//Settype ($ Val, string); Convert Val to string type
// GetType ($ name) Get the $ name 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.