码迷,mamicode.com
首页 > Web开发 > 详细

PHP Functions

时间:2014-08-14 10:37:28      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   使用   os   io   

PHP Array 函数

定义和用法

array_shift() 函数删除数组中的第一个元素,并返回被删除元素的值。

注释:如果键是数字的,所有元素都将获得新的键,从 0 开始,并以 1 递增

带有数字键:

<?php
$a=array(0=>"Dog",1=>"Cat",2=>"Horse");
echo array_shift($a);
print_r ($a);
?>

 

输出:

Dog
Array ( [0] => Cat [1] => Horse )

PHP String 函数

定义和用法

ucfirst() 函数把字符串中的首字符转换为大写。

 

Example #1 call_user_func_array()例子

<?php
function foobar($arg, $arg2) {
    echo __FUNCTION__, " got $arg and $arg2\n";
}
class foo {
    function bar($arg, $arg2) {
        echo __METHOD__, " got $arg and $arg2\n";
    }
}


// Call the foobar() function with 2 arguments
call_user_func_array("foobar", array("one", "two"));

// Call the $foo->bar() method with 2 arguments
$foo = new foo;
call_user_func_array(array($foo, "bar"), array("three", "four"));
?>

 

以上例程的输出类似于:

foobar got one and two
foo::bar got three and four

ob_start

(PHP 4, PHP 5)

ob_start — 打开输出控制缓冲

说明

bool ob_start ([ callback $output_callback [, int $chunk_size [, bool $erase ]]] )

此函数将打开输出缓冲。当输出缓冲激活后,脚本将不会输出内容(除http标头外),相反需要输出的内容被存储在内部缓冲区中。

内部缓冲区的内容可以用 ob_get_contents() 函数复制到一个字符串变量中。 想要输出存储在内部缓冲区中的内容,可以使用 ob_end_flush() 函数。另外, 使用 ob_end_clean() 函数会静默丢弃掉缓冲区的内容。

 

 

 

preg_replace

(PHP 4, PHP 5)

preg_replace — 执行一个正则表达式的搜索和替换

 

PHP list() 函数

<?php
$my_array = array("Dog","Cat","Horse");

list($a, $b, $c) = $my_array;
echo "I have several animals, a $a, a $b and a $c.";
?>

 

PHP Functions,布布扣,bubuko.com

PHP Functions

标签:des   style   blog   http   color   使用   os   io   

原文地址:http://www.cnblogs.com/lfzark/p/3911687.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!