Re: Re: Eval a file, and it gives parse error because it uses a preg_match statement with \$

From: Date: Fri, 06 Aug 2004 02:49:16 +0000
Subject: Re: Re: Eval a file, and it gives parse error because it uses a preg_match statement with \$
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.general 
Request: Send a blank email to php-general+get-192954@lists.php.net to get a copy of this message
Josh Acecool M wrote:
You dont understan.. Say the template is: Blah {CONTENT} adasdasd I want to preg_replace("/{CONTENT}/", include("blah.php"), $text); blah.php contains Hello! This is what appears Hello! Blah adasdasd
That's exactly what's supposed to happen. PHP encounters your preg_replace line. Within that line, before any output, PHP encounters your include() statement. So, it includes the file, sends it as output, returns nothing and then goes back to your preg_replace. It then replaces {CONTENT} with the nothing returned from include() and returns the result. What are the _exact results_ when you use file_get_contents()? $output = preg_replace('/\{CONTENT\}/',file_get_contents('blah.php'),$text); -- John Holmes php|architect - The magazine for PHP professionals - http://www.phparch.com

« previous php.general (#192954) next »