<?php
$site='php.cn';
function Dizhi($webdizhi)
{
return $webdizhi .'欢迎你';
}
echo Dizhi($site);
<?php
$name ='peter zhu';
$age = 30;
$ismarried=false;
echo '年龄:'.$age.'<br>';
echo '是否已婚?:' . $ismarried.'<br>';
echo '姓名:'.$name.'<br>';
echo '姓名中的第三个字母:'.$name{2}.'<br>';
echo print ('年龄:'.$age.'<br>');
//echo '<br>';
//print_r($name);
//echo '<br>';
//echo '姓名是:'.print_r($name,true).'<br>';
//$data= range(1,20,2);
//echo '<pre>'.print_r($data,true).'</pre>';
//var_export($name);
echo '<hr>';
//var_export($data);
var_dump($name,$age,$ismarried);
<?php
$user =[];
$user[] =101;
$user[] ='admin';
$user[] ='admin@php.cn';
$user=[101,'admin','admin@php.cn'];
echo $user[2].'<hr>';
echo '<pre>'.print_r($user,true).'</pre>';
echo '<hr>';
$res='';
for ($i=0; $i < count($user); $i++ ){
$res .=$user[$i].',';
}
echo rtrim($res,', ');
echo '<hr>';
$res='';
foreach ($user as $item){
$res .=$item.', ';
}
echo rtrim($res,', ');
echo'<hr>';
list($id,$name,$email)=$user;
echo $id.'-'.$name.$email;
$str = implode(',',$user);
echo '<br>'.$str .'<br>';
$sql="INSERT `users` SET `comment`='{$str}';";
$arr=explode(',',$str);
print_r($arr);
echo'<br>';
echo'<hr>';
$user =['id'=>101,'name'=>'admin','email'=>'admin@php.cn'];
//echo $user['email'];
//echo '<br>';
//echo '<pre>'.print_r($user,true).'<br>';
//遍历
foreach ($user as $key=>$value){
echo '['.$key.']=>'.$value.'<br>';
// echo [$key]=>$value;
}
$res = '';
for ($i = 0 ; $i <count($user); $i++){
$res.=current($user).', ';
next($user);
}
echo rtrim($res,', ');
echo'<hr>';
extract($user);
echo 'id2 = '. $id .'<br>'.'name=' .$name . '<br> email=' .$email.'<br>';
$dsn = 'mysql:host=localhost;dbname=demo';
$username='root';
$password='root';
$hebing=compact('dsn','username','password');
print_r($hebing);
echo'<br><hr>';
$arr=array_values($user);
echo '<pre>'.print_r($arr,true).'</pre>';
手抄: