You are here: preg_replace -- classes in replacement « All PHP « IT news, forums, messages
preg_replace -- classes in replacement

Posted by Al13n on 09/30/85 11:31

I have a class I want to apply to the replacement in a preg_replace
routine. While I can apply a function to this output with the /e flag, I
can't seem to get classes to work, I get a "non-static method ... cannot be
called statically" error, but I'm not entirely sure what to make of it.

I stripped the function out of the class for testing, and it works just
fine using this (the find/replace are in an array as this is only one of
several filters applied to some text)
array('/:time([-]?[0-9]{1,2})/ime',"date('g:i a',makeTime('$1'))" ),

I've called a new instance of the class, $makeTime = new makeTime();
and when used as a standalone, it works just fine -- but in the preg, no
dice.

I've tried using $makeTime->makeTime('$1') in place of the makeTime()
function call, have experimented with and without the e flag--but just
can't get it to work.

Historically, I haven't used classes as much as I should so I'll admit to
being a bit rusty ing a bit naive when it comes to using them in more
nonstandard places, like this . . . meh.

Thanks

A.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация