Re: regex for PHP variable name



Tom a écrit :
"Sebosac" <sebosac@xxxxxxxxxx> wrote in message
news:1179425971_309@xxxxxxxxx
hi, novice on regex, i'm searching for THE master Regex will retieve php
variable name like "$varname" in my script.


$tagparse = fil_gzet_contents('myscript.php');
preg_match_all("(.\$)", $tagparse, $out );


thank for your help

What at you trying to find in "myscript.php", any variable names? Maybe
something like this...

preg_match_all("/\$\S+/", $tagparse, $out );

Should do a pattern match for "$" and any not whitespace characters after
the dollar sign.

Tom

here what i'm trying to do :


"myscript.php" ccontaint someyhing like this :


$_Runtime_conf['config']['runtime']['_PRINCIPAL_CAT_SUBINDEXES_']=_CORE_MODULES_PRINCIPAL_MODULES_INDEXES($lien[1] );

foreach($_Runtime_conf['config']['runtime']['_PRINCIPAL_CAT_SUBINDEXES_'] as $dref){
//echo( "<a href=\"?p=".$dref[7]." \" class=\"poggle_blue\" > ".$dref[8]."</a>&nbsp;&nbsp;" );
echo("<li><a href=\"?p=".$dref[1]."\"> ".$dref[8]."<span></span></a></li>");
all_menu_site_map($dref);

}

and the reason of i need a regexp is to retrieve php Variable and Function name to Eval() them.

i work on a Content System Manager, atemplate like system, after all my try, a simple get_file_content, replace keywork and finish with eval() on php code was unsuccessful and eval set me to "error in eval's code at line 1", why, i can't explain this.


.



Relevant Pages

  • Re: [PHP] Deny processing of non included files
    ... One simple way to be sure it's not access directly by the browser is ... Then it can't be surfed to AT ALL, much less executed as PHP code. ... files generates a hash, stores it in the db for the length of the ... For that matter, your script should error out gracefully if, in the ...
    (php.general)
  • Re: 2 x quad-core system is slower that 2 x dual core on FreeBSD
    ... what, script or static html? ... In this thread, it's always PHP code, with database backends. ... pecl-APC) and of data (eAccelerator, ... and IPC). ...
    (freebsd-stable)
  • Re: from mysql to php
    ... the generated php code I have in mind would be used, e.g., in an installation procedure to generate the tables of the database. ... You could use phpMyAdmin to dump your existing structure into a file, incorporating it into your install script, using your text editor's search & replace capabilities to wrangle the dump into shape. ...
    (alt.php)
  • Is there any sort of preprocessor functionality in PHP4?
    ... I have a big tree of "if" statements (imagine the PHP code ... If I insert a new end-branch, ... script that would occur prior to execution. ...
    (comp.lang.php)
  • Re: [PHP] file_get_contents
    ... BTW, Brad, I was stripping the HTML tags around the object ok, but I'm ... but it's still showing php code in the text area! ... php is transparently making a http request to the webserver there is no ... way the webserver will differentiate between your script and every other request ...
    (php.general)