Deprecated: Function split() is deprecated

1 개요[ | ]

Deprecated: Function split() is deprecated

2 예제 1[ | ]

수정 전
<?php
$passwd_line = "root:x:0:0:root:/root:/bin/bash";
list($user, $pass, $uid, $gid, $extra) = split(":", $passwd_line, 5);
echo "user=[$user], pass=[$pass], uid=[$uid], gid=[$gid], extra=[$extra]";
// Deprecated: Function split() is deprecated in /var/www/html/php/split1.php on line 3
// user=[root], pass=[x], uid=[0], gid=[0], extra=[root:/root:/bin/bash]
수정 후
<?php
$passwd_line = "root:x:0:0:root:/root:/bin/bash";
list($user, $pass, $uid, $gid, $extra) = explode(":", $passwd_line, 5);
echo "user=[$user], pass=[$pass], uid=[$uid], gid=[$gid], extra=[$extra]";
// user=[root], pass=[x], uid=[0], gid=[0], extra=[root:/root:/bin/bash]

3 예제 2[ | ]

수정 전
<?php
$date1 = "04/30/1973";
$date2 = "04-30-1973";
$date2 = "04.30.1973";
list($month1, $day1, $year1) = split('[/.-]', $date1);
list($month2, $day2, $year2) = split('[/.-]', $date2);
list($month3, $day3, $year3) = split('[/.-]', $date2);
echo "Month: $month1; Day: $day1; Year: $year1<br />\n";
echo "Month: $month2; Day: $day2; Year: $year2<br />\n";
echo "Month: $month3; Day: $day3; Year: $year3<br />\n";
// Deprecated: Function split() is deprecated in /var/www/html/php/split2.php on line 5
// Deprecated: Function split() is deprecated in /var/www/html/php/split2.php on line 6
// Deprecated: Function split() is deprecated in /var/www/html/php/split2.php on line 7
// Month: 04; Day: 30; Year: 1973
// Month: 04; Day: 30; Year: 1973
// Month: 04; Day: 30; Year: 1973
수정 후
<?php
$date1 = "04/30/1973";
$date2 = "04-30-1973";
$date3 = "04.30.1973";
list($month1, $day1, $year1) = preg_split('/[\/\.-]/', $date1);
list($month2, $day2, $year2) = preg_split('/[\/\.-]/', $date2);
list($month3, $day3, $year3) = preg_split('/[\/\.-]/', $date3);
echo "Month: $month1; Day: $day1; Year: $year1<br />\n";
echo "Month: $month2; Day: $day2; Year: $year2<br />\n";
echo "Month: $month3; Day: $day3; Year: $year3<br />\n";
// Month: 04; Day: 30; Year: 1973
// Month: 04; Day: 30; Year: 1973
// Month: 04; Day: 30; Year: 1973

4 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}