首页 > 语言 > PHP > 正文

PHP通过引用传递参数用法分析

2024-05-04 23:53:06
字体:
来源:转载
供稿:网友

本文实例讲述了PHP通过引用传递参数用法。分享给大家供大家参考,具体如下:

先看一个手册上的示例:

<?phpfunction 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.

如果没有这个&符号,

<?phpfunction 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程序设计有所帮助。


注:相关教程知识阅读请移步到PHP教程频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选