The SUBSTR function is a little different in Perl and PHP
Published on April 13, 2009 in Hi.baidu
Use substr Same code in Perl and PHP, with different results.
Php:
<?php $addtime = "2009-04-13"; $datetime = "2008-12-31 12:00:00"; substr ($datetime, 0,10) = $addtime; Echo $datetime;? >
Compile error: Can ' t use function return value in write context
Perl:
#!/usr/bin/perl-wuse strict;my $addtime = "2009-04-13"; my $datetime = "2008-12-31 12:00:00"; substr ($datetime, 0,10) = $ad Dtime;print $datetime;
Result: 2009-04-13 12:00:00
SUBSTR in Perl can intercept replacements, and PHP can be replaced with the Substr_replace function.
PHP's Substr_replace function uses:
<?php $addtime = "2009-04-13"; $datetime = "2008-12-31 12:00:00"; $datetime = Substr_replace ($datetime, $addtime, 0,10); Echo $datetime;? >
The SUBSTR function is a little different in Perl and PHP