Blogger Information
Blog 13
fans 0
comment 0
visits 6744
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php基础知识--2018年8月26日22时13分作业
七分钟的记忆的博客
Original
676 people have browsed it

实例

<meta charset="UTF-8">

<?php


echo "函数的基本知识","<hr>";

function hello ($siteName)
{
  return "欢迎来到".$siteName."中文网学习";
}
echo hello("php");


echo "<hr>";

function hello1 ($siteName2,$siteName1="学习")
{
   return "欢迎来".$siteName2."中文网".$siteName1;
}
echo hello1("php、java");

echo "<hr>";

function hello2 ($a,$b,$c)
{
     // return func_num_args();  返回数量
      // return func_get_arg(0);  返回索引对应的值
      // return print_r(func_get_args(),true);   返回数组
      return (func_get_arg(0)+func_get_arg(1)+func_get_arg(02));
      // return ($a+$b+$c);

}
echo hello2(5,8,9);

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

<meta charset="UTF-8">
<?php


echo "数组的内部操作","<br>";

$user =["id"=>5,"name"=>"sun","gender"=>"male","age"=>25];

// print_r(in_array("sun",$user)?"存在" : "不存在");  /*判断数组中是否存在某个值*/

// echo "<pre>",print_r($user,true);

// print_r(array_key_exists("id1",$user)? "存在" : "不存在");   //判断数组健名是否存在

// echo "<hr>";
// print_r(array_values($user));  //以索引的返回对应的值

// print_r(array_keys($user));    //以索引的返回对应的健

// print_r(array_search(25,$user));  // 以指定的方式返回那个值对应的健
// print_r(array_flip($user));




// 数组中的内部操作

echo count($user),"<br>";   //返回数量
echo key($user),"<br>";   //返回当前第一个数组的健
echo current($user);  //返回当前第一个数组的值

echo next($user);  //移动到下一位

echo "<hr>";
echo key($user);
echo current($user);

echo "<hr>";

reset($user);   // 复位
echo key($user),"<br>";
echo current($user);

echo "<hr>";

end($user);   //返回到尾部
echo key($user);
echo current($user);

echo "<hr>";

echo "<pre>",print_r(each($user));

reset($user);
// 数组的遍历
echo "<hr>";
list($key, $value) = each($user);

echo $key, '******', $value,'<hr>';

while (list($key,$value) = each($user)) {
    echo $key,"....",$value."<br>";
}

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

<meta charset="UTF-8">
<?php

echo "使用数组来模拟堆栈和队列操作";

echo "<hr>";
$user =["id"=>5,"name"=>"sun","age"=>25];
//   echo "<pre>",print_r($user);
// echo "<hr>";
// echo count($user);

// print_r(array_push($user,"php中文网","php"));  //尾部添加
// echo "<pre>",print_r($user,true);
// echo count($user);

// print_r(array_pop($user));   // 尾部删除
// echo "<pre>",print_r($user,true);

// echo "<hr>";
// print_r(array_unshift($user,"php","java"));  //头部添加
// echo "<pre>",print_r($user,true);
// echo "<hr>";

// print_r(array_shift($user));         //头部删除
// echo "<pre>",print_r($user,true);
//
//
//
//模拟队列操作: 增删只能在二端进行,不允许同一端进行

array_push($user,"php");  //尾部进队
echo "<pre>",print_r($user,true);

array_shift($user);  //头部删除
print_r($user);

array_unshift($user,"java");    //头部进队
print_r($user);
array_pop($user);
print_r($user);

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post