这里有新鲜出炉的 PHP 教程,程序狗速度看过来!
PHP(外文名: Hypertext Preprocessor,中文名:"超文本预处理器")是一种通用开源脚本语言。语法吸收了 C 语言、Java 和 Perl 的特点,入门门槛较低,易于学习,使用广泛,主要适用于 web 开发领域。PHP 的文件后缀名为 php。
这篇文章主要介绍了 PHP 通过引用传递参数用法, 结合具体实例分析了 php 函数参数中使用引用进行参数传递的功能与操作技巧, 需要的朋友可以参考下
本文实例讲述了 PHP 通过引用传递参数用法。分享给大家供大家参考,具体如下:
先看一个手册上的示例:
- <?php
- function add_some_extra(&$string) // 引入变量,使用同一个存储地址
- {
- $string .= 'and something extra.';
- }
- $str = 'This is a string, ';
- add_some_extra($str);
- echo $str; // outputs 'This is a string, and something extra.'
- ?>
输出:
- This is a string, and something extra.
如果没有这个 & 符号,
- <?php
- function add_some_extra($string)
- {
- $string .= 'and something extra.';
- }
- $str = 'This is a string, ';
- add_some_extra($str);
- echo $str; // outputs 'This is a string, '
- ?>
输出:
- This is a string,
希望本文所述对大家 PHP 程序设计有所帮助。
来源: http://www.phperz.com/article/17/0809/340973.html