Home > Backend Development > PHP Tutorial > PHP study notes (2) data types

PHP study notes (2) data types

WBOY
Release: 2016-07-29 08:49:47
Original
970 people have browsed it
";/* C style */"; # C++ single line comment style?>11" "Single quotesSingle quotes will be treated as ordinary strings Output$i='hello,world!';echo "$i";$i(boolean)141516171819Return TRUE on success, or FALSE on failure$foo = "5bar"; // string$bar = true; // booleansettype($bar, "string"); // $bar is now "1" (string)
Serial number Symbol Name Function Remarks
1 echo Output character Same as python’s print statement
will be immediately followed by The string or variable value after is displayed on the page
2 ; semicolon is used after the code to indicate the end
3 ?> XML Markup style is used to include code to distinguish it from html code
Recommended, the server cannot be disabled
echo "hello, world!";
?>
4 < ;script language="php">
script style
5 ?> Short style Short style and ASP style need to be set in php.ini, set both short_open_tag and asp_tags to ON echo 'hello, world!';
?>
6 <%
%>
ASP style Short style and ASP style need to be set in php.ini, set both short_open_tag and asp_tags for ON <%
echo 'hello, world!';
%>
7 // comment symbol C++ style echo " "
echo "
 
Multi-line comments?> 9 #

comment symbol

shell style

echo "
 
10 $ variable identifier All variables must be preceded by the '$' symbol

' 'Double quotes Variables contained in double quotes will be automatically replaced with actual values
echo "

";
echo '$i';?>

Display results
hello ,world!

12

<<<

definator



13
convert to Boolean(boolean)$num, (boolean) $str
(string)converted into character type(string)$boo, (string)$flo
(integer)converted into integer type( integer)$boo, (integer)$str
(float)convert to floating point type(float)$str
(array)convert to array (array)$str
(object)Convert to object(object)$str
settype()type conversion functionsettype(needs to be converted Variable, converted type)
settype($foo , "integer"); // $foo is now 5 (integer)?>
The above introduces PHP study notes (2) data types, including PHP learning and data types. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template