php 字符串的连接、分割,数组、include require

<pre name="code" class="php"><?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/7/7 0007
 * Time: 22:49
 */

/*数组*/
$arr=array();
$arr[0]='hello';
$arr[1]='nihao';
$arr[2]='woshixuexi';
$arr[3]=20;

for($i=0;$i<10;$i++){
    array_push($arr,'item'.$i);//增加元素到数组未端
}

print_r($arr);




<?php/** * Created by PhpStorm. * User: Administrator * Date: 2016/7/7 0007 * Time: 22:23 *///字符串$str='hello php java javascript';//下标从1开始。//echo strpos($str,'lan');//substr下标从零开始。substr(字符串,开始,结束)//echo $substr=substr($str,2);//分割字符串,返回数组//$result=str_split($str);//echo print_r($result);//以空格分割字符串//$result=explode(" ",$str);//echo print_r($result);//使用.作为连接符echo $str2=$str."\t".'我是学习 的';








/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/7/7 0007
 * Time: 23:10
 */

//两者作用一样。提示错误有区别。
//require 'lib.php';只能定义一次
//include 'lib.php';


require_once 'lib.php';
require_once 'lib.php';
sayHello();

 

你可能感兴趣的:(JavaScript,PHP,html5)