Re: Parsing PHP code from PHP

From: Date: Wed, 09 Apr 2003 07:29:59 +0000
Subject: Re: Parsing PHP code from PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143017@lists.php.net to get a copy of this message
On Tue, 2003-04-08 at 14:57, luis wrote: > Hi all, > > I'm writing an application where the user can edit PHP scripts that are > later executed. > (All the security considerations can be supressed in replies) > I want to know if you know some PHP parser in PHP that could be used to > parse the scripts and inform the user if there're parsing errors in the > scripts they edited. I don't know how accurate this would be, but .... You could run a massive regexp against the supplied PHP code. This would be the same thing that most text editors that offer PHP highlighting do, although they use a better method than regexps. If the statements don't conform to the regexp for valid statements, then you will get parse errors if you were to execute them on the server. I am curious as to why command-line PHP is not an option. That would be the ideal solution -- with a bit of command line redirection, you could easily solve this problem. -- Burhan Khalid phplist[at]meidomus[dot]com Please add a reply-to: header in your messages that points to the mailing list address so that all mail is properly archived and viewed.

« previous php.general (#143017) next »