源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2021-06-09 20:51 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要: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相关内容感兴趣的读者可查看本站专题:《[url=http://www.1sucai.cn/Special/168.htm]php常用函数与技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/43.htm]php面向对象程序设计入门教程[/url]》、《[url=http://www.1sucai.cn/Special/630.htm]PHP数学运算技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/623.htm]PHP数组(Array)操作技巧大全[/url]》、《[url=http://www.1sucai.cn/Special/614.htm]PHP数据结构与算法教程[/url]》、《[url=http://www.1sucai.cn/Special/111.htm]php程序设计算法总结[/url]》、《[url=http://www.1sucai.cn/Special/180.htm]php正则表达式用法总结[/url]》及《[url=http://www.1sucai.cn/Special/231.htm]php常见数据库操作技巧汇总[/url]》 希望本文所述对大家PHP程序设计有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部