www.webdeveloper.com
Results 1 to 5 of 5

Thread: strange signs in joomla plugin!

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Posts
    61

    strange signs in joomla plugin!

    Hi!

    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:

    Code:
    $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>';
    	}
    "([a-zA-Z0-9_-]+))|e" what is that? :O

    (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 ^^)

    I've seen these all over.. In strings and stuff.. And some in JavaScript too..

    What are they for, what do they mean, and how can I use them to help me?

    Cheers,
    Artheus

  2. #2
    Join Date
    Jan 2009
    Posts
    3,346
    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.

  3. #3
    Join Date
    Apr 2007
    Posts
    1,664
    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).

  4. #4
    Join Date
    Sep 2008
    Posts
    61

    thanks

    thanks alot for the link!

    I will read through all that tomorrow and try to get a picture of it all ^^

    Cheers,
    Artheus

  5. #5
    Join Date
    Apr 2007
    Posts
    1,664
    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 .

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles