前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >php入门操作

php入门操作

作者头像
闵开慧
发布2018-03-30 13:46:24
9260
发布2018-03-30 13:46:24
举报
文章被收录于专栏:闵开慧闵开慧
代码语言:javascript
复制
<?php

/**
 * @author minguanghui
 * @copyright 2012
 */
$str="Hello everyone!<br>";
$i=6;
$string="morning everybody!<br>";
print($str);
print("ÄãºÃ£¡<br>");
print($string);
echo($i);
echo $i;
/*
if else ÅжÏ
*/
$d=date("Mon");
print $d;
print "<br>";
if($d=="Fri")
    echo "Have a nice weekend!<br>";
elseif($d=="Mon")
    echo "Today is Monday!<br>";
else
    echo "Today is not Friday!<br>";
print "good!";

/*
switch
*/
print "<br>";
$x=3;
switch($x){
    case 1:
        echo "Number 1.";
        break;
    case 2:
        echo "Number 2.";
        break;
    case 3:
        echo "Number 3.";
        break;
    default:
        echo "There is no number.";
}

/*
Êý×é
*/
print "<br>";
$names=array("aaa","bbb","ccc","ddd");
echo $names[0]." and ".$names[1]." is ".$names[2]."'s neighber.";

/*
while
*/
print "<br>";
$x=0;
while($x<100){
    echo $x." ";
    $x++;
}

/*
for
*/
print "<br>";
for($i=0;$i<100;$i++){
    echo $i." ";
}

/*
foreach
*/
print "<br>";
$array=array("one","two","three","four","five");
$length=count($array);
for($i=0;$i<$length;$i++){
    print $array[$i]." ";
}
print "<br>";
foreach($array as $values){
    print $values." ";
}

/*
function
*/
print "<br>";
function printName(){
    echo "Your name.";
}
printName();

function printString($m){
    for($i=0;$i<$m;$i++){
        print $i." ";
    }
}
printString(100);

print "<br>";
function add($i, $j){
    return $i+$j;
}
echo add(3,4);

/*
date
*/
print "<br>";
echo date("Y/m/d");
echo "<br>".date("Y.m.d");
echo "<br>".date("Y-m-d");
$date=date("now");
echo "<br>".$date;

/*
file
*/
print "<br>";
$file=fopen("E:\\test.txt","r") or exit("The file is not exit.");
while(!feof($file)){
    echo fgets($file)."<br>";
}
fclose($file);

$file=fopen("E:\\test.txt","r") or exit("The file is not exit.");
while(!feof($file)){
    echo fgetc($file);
}
fclose($file);

print "<br>";
$a=56;
echo gettype($a)."<br>";
$a=2342314.233242;
echo gettype($a)."<br>";
settype($a,'boolean');
echo gettype($a)."<br>";
echo is_double($a);
echo isset($a)."<br>";
echo isset($b);
echo empty($a)."<br>";
echo empty($c)."<br>";




/*
phpÊäÈë
*/
/*
$s=fgets($stdin);
echo "The input is {$s}";
?>
<script Language="JavaScript">
function ctlent(eventobject)
{
if(event.ctrlKey && window.event.keyCode==13)
{
this.document.frmAnnounce.submit();
}
}
}
</script>
<form action="" method=POST name=frmAnnounce>
<textarea class=smallarea cols=95 name=Content rows=12 wrap=VIRTUAL title=¿ÉÒÔʹÓÃCtrl+EnterÖ±½ÓÌá½»Ìù×Ó class=FormClass onkeydown=ctlent()></textarea>
</form>
*/
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档