On Thu, 5 Aug 2004 22:32:54 -0700, Josh Acecool M <[EMAIL PROTECTED]> wrote: > IF I do this: > > $text = file_get_contents('templateFile.php'); > $text = preg_replace('/something/', include("something.php"), $text); > then it gets put ON TOP of the file, not where "something" is... > > see what I am saying? >
It's still not "on top of the page", it's right in that line of code where you asked for it. Include would return "true" as it included the page and your $text doesn't have what you wanted it to have. This is obvious as include() doesn't return the code, it runs the file. > but, I am doing this. > > $text = file_get_contents('templateFile.php'); > $text = preg_replace('/something/', file_get_contents("something.php"), > $text); > eval("?>" . $text . "<?") Ok, finally the "real" code. So you are doing processing on the file before eval-ing it. Please show us the real regex. Are you actually doing this this way? *WHY*? Likely your problem is that the contents of something.php has a $ in it (duh, it's PHP) and preg_replace is trying to put something there. If you show us the actual code you're using *maybe* we can help. How about something different: $text = file_get_contents('templateFile.php'); $chunks = preg_split('/something/', $text); eval('?>'.$chunks[0].'<?'); include("something.php"); eval('?>'.$chunks[1].'<?'); > > "Justin Patrin" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Thu, 5 Aug 2004 21:42:58 -0700, Josh Acecool M > > <[EMAIL PROTECTED]> wrote: > > > 5.0.0 > > > > > > Include WORKS, but using INCLUDE with PREG_REPLACE does NOT work, the > text > > > you want to replace gets deleted and the INCLUDE includes on the top of > the > > > page... > > > > You're not making sense....you're saying that using preg_replace *in* > > the included code doesn't work? That can't be what you mean. > > > > Including a file does *not* include it "at the top of the page". It's > > included wherever you put the include statement. You can put them > > *anywhere*, not just at the top of the page. See the DB::connect() > > method in PEAR DB for an example. > > > > http://cvs.php.net/co.php/pear/DB/DB.php?r=1.59 > > > > If what you're saying is that the output goes to the browser, you can > > use the output buffering functions to catch the output. > > > > http://us3.php.net/manual/en/ref.outcontrol.php > > > > If what you're doing is similar to this: > > $text = file_get_contents('templateFile.php'); > > $text = preg_replace('/something/', 'something else', $text); > > eval($text); > > > > Then you *are* changing the text before eval-ing it (you never > > answered the many questions about this). If this is what you are > > doing, then it sounds like the issue is not in the eval or the > > included file, but in the preg_replace. Please give us the exact > > preg_replace line that you are using and what it is supposed to do so > > we can help with your regex. > > > > > > > > "Justin Patrin" <[EMAIL PROTECTED]> wrote in message > > > news:[EMAIL PROTECTED] > > > > > > > > > > On Thu, 5 Aug 2004 09:51:10 -0700, Josh Acecool M > > > > <[EMAIL PROTECTED]> wrote: > > > > > The files that are evaled work perfectly without being evaled. > > > > > > > > > > I dont think eval was meant for large files etc. > > > > > > > > > > Whats on that like: a preg_match that looks for \$variable = > something; > > > > > > > > > > and thats the like it messes up on. > > > > > > > > > > Also, if the file which is evaled includes another file, the > variables > > > from > > > > > the included file wont get parsed or anything, and the variables set > to > > > it > > > > > by the first file, or the class dont work at all. > > > > > > > > > > > > > What version of PHP are you using? > > > > > > > > Are you doing anything to the string before eval-ing it? You say that > > > > if you just include() is, it works fine. *Why* not just include it, > > > > then? > > > > > > > > > "John Holmes" <[EMAIL PROTECTED]> wrote in message > > > > > news:[EMAIL PROTECTED] > > > > > > > > > > > > > > > > Josh Acecool M wrote: > > > > > > >>> var $The_Template_Sys; > > > > > > >>> > > > > > > >>>$this -> The_Template_Sys = > > > file_get_contents("$The_Template_File"); > > > > > > >>> > > > > > > >>>$this -> Sub_Template = TRUE; > > > > > > > Any ideas? > > > > > > > > > > > > I have an idea I said in a previous email! > > > > > > > > > > > > >>you say you're getting a parse error. How could anyone possibly > help > > > you > > > > > > >>troubleshoot that parse error unless they had an example of what > was > > > in > > > > > > >>the file being eval()'d?? > > > > > > > > > > > > What is actually in the file that's failing the eval()??!?!?! What > > > line > > > > > > of the file is failing? What is on that line? What's on the couple > of > > > > > > lines before it? What's on the couple of lines after that line > that's > > > > > > failing? What does the line with the eval() call look like? Are > you > > > > > > doing anything else with $this->The_Template_Sys before it's > > > > > eval()'d?????? > > > > > > > > > > > > -- > > > > > > > > > > > > John Holmes > > > > > > > > > > > > php|architect - The magazine for PHP professionals - > > > > > http://www.phparch.com > > > > > > > > > > > > > -- > > > > DB_DataObject_FormBuilder - The database at your fingertips > > > > http://pear.php.net/package/DB_DataObject_FormBuilder > > > > > > > > paperCrane --Justin Patrin-- > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- > > DB_DataObject_FormBuilder - The database at your fingertips > > http://pear.php.net/package/DB_DataObject_FormBuilder > > > > paperCrane --Justin Patrin-- > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php