201710 PHP 函数回顾

1、strpos

mixed  strpos (  string $haystack ,  mixed $needle [,  int $offset = 0 ] )

Find the numeric position of the first occurrence of needle in the haystack string.

查找$needle在字符串$haystack中出现的位置。

特别注意可能返回位置0以及查找不到的时候返回false,所以比较的时候注意要用===或者!==

$offset代表偏移量,例如下面的例子,返回值是7而不是0

<?php
// We can search for the character, ignoring anything before the offset
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0
?>
2、

basename(__FILE__)

basename() 函数返回路径中的文件名部分。


详细用法再研究


3 str_replace()

<?php
echo str_replace("world","Shanghai","Hello world!");
?>

// Hello Shanghai!

4 dirname()

函数返回路径中的目录部分。

<?php
echo dirname("c:/testweb/home.php");
echo dirname("/testweb/home.php");
?>
//

c:/testweb
/testweb

5 string   getcwd  (  void  )


获得当前的工作目录


substr() 函数返回字符串的一部分。

注释:如果 start 参数是负数且 length 小于或等于 start,则 length 为 0。





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值