Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

split Deprecated



11:03 pm on May 29, 2012 (gmt 0)

I was given code that is for password protecting a site. When I try to change the password the site tells me the function split is deprecated. So I looked it up and was told to use preg_split instead.

When I try to use that I get an error message:

Warning: preg_split() [function.preg-split]: Empty regular expression in /home/mmoprotools/www/secure/globalFns.php on line 5

Warning: Cannot modify header information - headers already sent by (output started at /home/mmoprotools/www/secure/globalFns.php:5) in /home/mmoprotools/www/secure/admin/resetPwd.php on line 33

The Code for the first error is :
require_once(dirname(__FILE__) . "/menus.php");

function getFirstName($fullName) {
$parts = split(" ", $fullName);
return $parts[0];

Any suggestions would be greatly appreciated! Thanks!


2:37 am on May 30, 2012 (gmt 0)

I no longer need an answer to this. I'm using something else now.


6:58 am on May 30, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

The sample code you supplied didn't contain


2:33 pm on May 30, 2012 (gmt 0)

I suspect the issue was that you simply changed
without also changing the first argument. The relevant line should be:

$parts = preg_split("/ /", $fullName);

Although using
[us3.php.net] may be better in this case.



4:19 pm on May 30, 2012 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Agreed, any single character is not really a pattern, any of the 'reg functions are meant to match on patterns. :-)


6:16 pm on May 30, 2012 (gmt 0)

5+ Year Member

I know this might seem obvious, but it seems to be frequently misunderstood.

When you get a PHP warning that says "____ is deprecated. Use ____ instead", it doesn't mean that you should just change the name of the function.

It means that you should go to the PHP manual ( [php.net...] ), look up the function you were using, look up the new function, and change your code so it uses the new function properly, using the rules and requirements for its use.

The two functions are often very similar, but they won't be exactly the same.

Featured Threads

Hot Threads This Week

Hot Threads This Month