php study note 2 --- basic syntax
来源:互联网 发布:网络舆情监测员工资 编辑:程序博客网 时间:2024/05/22 05:54
1. the fisrt php code
root@vinco:/var/www# ls\ index.html testphp w3cschool.phproot@vinco:/var/www# mv testphp test.php
<?phpinfo();?>
2. for() foreach() switch-case, if-else,if-elseif-else
root@vinco:/var/www# vim syntax1.php
<html><body><?php /* for variable and echo */ $txt="hello world"; echo $txt . " " . ","."vinco<br/>"; /* for if-elseif-else sentence */ $d=date("D"); if($d=="Fri") { echo "<br/>Hello!<br/>"; echo "Have a nice weekend!"; echo "See you on monday!<br/><br/>"; } elseif($d=="Sun") { echo "have a nice sunday<br/>"; } else { echo "have a nice workday<br/>"; } /* for array, for,foreach,switch--case sentence */ $week=array( "sunday"=>0,"monday"=>1,"tuesday"=>2,"wenesday"=>3,"thursday"=>4,"friday"=>5,"satday"=>6 ); for($day=$week['sunday'];$day <= $week['satday'];$day++) //foreach($week as $day) { switch($day) { case 0: echo "today is "."sunday!<br/> ";break; case 1: echo "today is "."monday!<br/> ";break; case 2: echo "today is "."tuesday!<br/> ";break; case 3: echo "today is "."wenesday!<br/> ";break; case 4: echo "today is "."thursday!<br/> ";break; default:break; } echo "<br/>"; } /* for function */ function add($x,$y) { $total=$x+$y; return $total; } echo "10+100 = ".add(10,100); /* for form */?> <form action="welcom.php" method="post"> Name:<input type="text" name="name" /><br/> Age   :<input type="text" name="age" /><br/> <input type="submit" /><br/> </form></body></html>
- php study note 2 --- basic syntax
- Study Note:CSIN3 Chapter 2: C# Language Basic
- REST&PHP study Note
- perl study note-2
- jQuery study note 2
- LDD3 study note 2
- MySql study note 2 ---mysqladmin
- DOJO Study Note(2) --AJAX
- Study Note: Logistic Regression(2)
- study note of "Zend PHP 5 Certification Study "--array
- study note of "Zend PHP 5 Certification Study "--OOP
- WPF Study Note 2: XAML Overview
- My study note of PHP language(I)
- My study note of PHP language(II)
- My study note of PHP language(III)
- My study note of PHP language(IV)
- My study note of PHP language(V)
- [TSP- Coaching Development Teams] Study Note#1 - basic principles for coaching
- spring入门 - Aware相关接口
- Android:Git、Repo、Gerrit服务器架构Android代码库
- Flex中生成Excel
- Android NDK开发之一hello world的可执行程序
- mysql Error 1130 远程连接访问 问题的解决方案
- php study note 2 --- basic syntax
- Access数据表导入到Sql server 2005
- JMS Apache ActiveMQ使用(1)
- 初学C++ container(容器) 顺序容器
- 10029 - Edit Step Ladders
- DeleteTree 函数
- Mongodb 的ORM框架 Morphia 之 Datasotre接口
- Linux设备模型之platform总线
- ActiveMQ使用(2)