我来给大家搞一个模拟字符串拷贝功能的小函数,供大家参考,有不足的地方请多多指教
- <?php
- function strcopy($s1, &$s2){
- if($s1 == "" || strlen($s1) <= 0 || !isset($s2)){
- return;
- }
- $slen = strlen($s1);
- for($i=0; $i<$slen; $i++){
- $s2 .= $s1[$i];
- }
- }
- $x = "http://www.91php.com/ 永余PHP技术社区";
- $y = "";
- strcopy($x, &$y);
- echo ($y);
- ?>
<?php
function strcopy($s1, &$s2){
if($s1 == "" || strlen($s1) <= 0 || !isset($s2)){
return;
}
$slen = strlen($s1);
for($i=0; $i<$slen; $i++){
$s2 .= $s1[$i];
}
}
$x = "http://www.91php.com/ 永余PHP技术社区";
$y = "";
strcopy($x, &$y);
echo ($y);
?>