Algemeen en interessant nieuws over en door NosTech


Ereg function has been deprecated since PHP 5.3
02-04-2015 10:00

Since PHP v5.3 the frequently used ereg-function has become depracted, here you can find back an overview of how most cases of using ereg can be fixed:

Old ereg() code:
ereg(’.([^.]*$)’, $this->file_src_name, $extension);
New replacement code:
preg_match(’/.([^.]*$)/’, $this->file_src_name, $extension);

Old ereg_replace()  code:
$this->file_dst_name_body = ereg_replace(’[^A-Za-z0-9_]’, “, $this->file_dst_name_body);
New replacement code:
$this->file_dst_name_body = preg_replace(’/[^A-Za-z0-9_]/’, ”, $this->file_dst_name_body);

Old eregi()  code:
eregi(’.([^.]*$)’, $this->file_src_name, $extension);
New replacement code:
preg_match(’/.([^.]*$)/i’, $this->file_src_name, $extension);

< Alle nieuws