<?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,

相关文章:

  • 2021-11-08
  • 2021-07-01
  • 2022-12-23
  • 2021-06-02
  • 2021-08-24
  • 2021-11-10
  • 2022-01-18
猜你喜欢
  • 2021-11-17
  • 2021-12-01
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
相关资源
相似解决方案