PHP开发实战权威指南,php实战指南_PHP教程

WBOY
풀어 주다: 2016-07-13 10:17:12
원래의
1039명이 탐색했습니다.

PHP开发实战权威指南,php实战指南

3.2.1 变量的声明与命名

<span> 1</span> <?<span>php
</span><span> 2</span>     <span>$title</span>="hello";   <span>//</span><span>正确</span>
<span> 3</span>     <span>$title123</span>="hello";  <span>//</span><span>正确</span>
<span> 4</span>     $123title="hello";  <span>//</span><span>错误</span>
<span> 5</span>     <span>$_title</span>="hello";     <span>//</span><span>正确</span>
<span> 6</span>     $@<span>#</span><span>title="hello";   //错误</span>
<span> 7</span>     <span>$url</span>="hello";   <span>//</span><span>我们得到一个变量url</span>
<span> 8</span>     <span>echo</span> <span>$url</span>;      <span>//</span><span>结果:hello</span>
<span> 9</span>     <span>unset</span>(<span>$url</span>);   <span>//</span><span>删除一个变量url</span>
<span>10</span>     <span>echo</span> <span>$url</span>;     <span>//</span><span>结果为空</span>
<span>11</span> ?>
로그인 후 복사

3.2.2 可变变量与引用赋值

<span>1</span> <?<span>php
</span><span>2</span>     <span>$var</span>="php"<span>;
</span><span>3</span>     <span>$php</span>="hello"<span>;
</span><span>4</span>     <span>echo</span> <span>$var</span>;   <span>//</span><span>输出结果php</span>
<span>5</span>     <span>echo</span> $<span>$var</span>;   <span>//</span><span>输出结果hello</span>
<span>6</span> ?>
로그인 후 복사

3.3.1 字符串

<span>1</span> <?<span>php
</span><span>2</span>     <span>$title</span>="hello"<span>;  
</span><span>3</span>     <span>echo</span> '$title,world';  <span>//</span><span>结果:$title,world</span>
<span>4</span>     <span>echo</span> "<span>$title</span>,world ";  <span>//</span><span>结果:hello,world</span>
<span>5</span>     <span>echo</span> "${title},world";  <span>//</span><span>结果:hello,world</span>
<span>6</span>     <span>echo</span> "{<span>$title</span>},world";  <span>//</span><span>结果:hello,world</span>
<span>7</span>     <span>echo</span> "\$title,world";  <span>//</span><span>结果:$title,world</span>
<span>8</span> ?>
로그인 후 복사

3.3.8 类型的强制转换与应用

<span>//</span><span>其他类型转换成整型</span>
<?<span>php
    </span><span>$php</span>=100.10<span>;
    </span><span>echo</span> (int)<span>$php</span>;  <span>//</span><span>输出结果:100</span>
    <span>$php</span>=<span>true</span><span>;
    </span><span>echo</span> (int)<span>$php</span>;  <span>//</span><span>输出结果:1</span>
    <span>$php</span>="123php"<span>;
    </span><span>echo</span> (int)<span>$php</span>;  <span>//</span><span>输出结果:123</span>
    <span>$php</span>="php123"<span>;  
    </span><span>echo</span> (int)<span>$php</span>;  <span>//</span><span>输出结果:0</span>
?>

<span>//</span><span>其他类型转化为字符串型</span>
<?<span>php
    </span><span>$php</span>=100.1<span>;
    </span><span>var_dump</span>((<span>string</span>)<span>$php</span>);  <span>//</span><span>输出结果:string(4)"100.1"</span>
    <span>$php</span>=<span>true</span><span>;
    </span><span>echo</span>(<span>string</span>)<span>$php</span>;  <span>//</span><span>输出结果:1</span>
?>

<span>//</span><span>其他类型转化为浮点型</span>
<?<span>php
    </span><span>$php</span>="123.2php"<span>;
    </span><span>var_dump</span>((<span>float</span>)<span>$php</span>);  <span>//</span><span>输出结果:float(123.2)</span>
    <span>$php</span>="php123.2"<span>;
    </span><span>var_dump</span>((<span>float</span>)<span>$php</span>);  <span>//</span><span>输出结果:(0)</span>
?>

<span>//</span><span>其他类型转化为布尔型</span>
<?<span>php
    </span><span>$php</span>="php"<span>;
    </span><span>var_dump</span>((bool)<span>$php</span>);  <span>//</span><span>输出结果:bool(true)</span>
    <span>$php</span>=0<span>;
    </span><span>var_dump</span>((bool)<span>$php</span>);  <span>//</span><span>输出结果:bool(false)</span>
?>
로그인 후 복사

 

想学习PHP语言制作网页设计,里面要有与网页设置后台程序联系在一起的实例有没有什书很好的?

《php和mysql web开发》
不过前台你还要会html javascript or jquery
 

想学习PHP语言制作网页设计,里面要有与网页设置后台程序联系在一起的实例有没有什书很好的?

《php和mysql web开发》
不过前台你还要会html javascript or jquery
 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/893871.htmlTechArticlePHP开发实战权威指南,php实战指南 3.2.1 变量的声明与命名 1 ? php 2 $title ="hello"; // 正确 3 $title123 ="hello"; // 正确 4 $123title="hello"; // 错误 5 $...
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿