strange signs in joomla plugin!
I've been quite curious about all the strange signs around in different php plugins which are open-source on the net.. And here is one example of which signs I'm thinking of:
"([a-zA-Z0-9_-]+))|e" what is that? :O
$article->text = preg_replace('|(http://www.youtube.com/watch\?v=([a-zA-Z0-9_-]+))|e', '$this->youtubeCodeEmbed("\2")', $article->text);
function youtubeCodeEmbed( $vCode )
$plugin =& JPluginHelper::getPlugin('content', 'youtubeembed');
$params = new JParameter( $plugin->params );
$width = $params->get('width', 425);
$height = $params->get('height', 344);
return '<object width="'.$width.'" height="'.$height.'"><param name="movie" value="http://www.youtube.com/v/'.$vCode.'"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/'.$vCode.'" type="application/x-shockwave-flash" allowfullscreen="true" width="'.$width.'" height="'.$height.'"></embed></object>';
(Might be a quite stupid question to ask... thinking of that I've been programming for almost 12 years now xD Though did I start for the PHP the last year, and hadn't heard of it before that ^^)
What are they for, what do they mean, and how can I use them to help me?
That is a regular expression. It is used to select or validate certain types of strings. In this case it looks like it is replacing a url that may have a string of characters following it with something returned from an object.
There called regular expressions and are used for pattern matching. Incredibly powerful and useful but they make your head hurt even when you do understand them (I half do and get by).
thanks alot for the link!
I will read through all that tomorrow and try to get a picture of it all ^^
I wish you the best of luck! There are a couple of regexp experts round here so post your questions, even very simple questions wont be laughed at!! Regexps are mighty difficult at first and then after that, just normal level of difficult .
Users Browsing this Thread
There are currently 2 users browsing this thread. (0 members and 2 guests)
Tags for this Thread