Jump to content


Photo

fwrite and <?PHP


  • Please log in to reply
5 replies to this topic

#1 mslater

mslater
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 24 May 2006 - 11:45 PM

Hello all,

I have a script that creates a new PHP file. I need the PHP file to actually contain the <?PHP and ?> lines, but when the script reaches the body of copy and finds "<?PHP" it comes to a hault.

Example
$copy = "<?PHP"

Is there anyway to comment that line so PHP will ignore it and write it into the new file?

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 25 May 2006 - 09:32 AM

What do you mean by "comes to a halt"? Does it give you any error messages? It shouldn't have a problem with assigning the value "<?php" to a variable...

#3 mslater

mslater
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 25 May 2006 - 01:02 PM

[!--quoteo(post=376940:date=May 25 2006, 05:32 AM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ May 25 2006, 05:32 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
What do you mean by "comes to a halt"? Does it give you any error messages? It shouldn't have a problem with assigning the value "<?php" to a variable...
[/quote]
It comes to a hault. It stops. No error message. The script works fine up to where the variable shows up and then stops. Granted it picks up whatever is AFTER "<?php" but the loose " at the end leaves everything a might screwy.

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 25 May 2006 - 01:06 PM

Could you post your code here please so we can see what you are doing.

PHP shouldn't shouldn't "halt" when you place <?php in a variable.

#5 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 25 May 2006 - 05:51 PM

try to add a ; after the code
$copy = "<?PHP";

NoGray.com


#6 mslater

mslater
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 25 May 2006 - 06:02 PM

[!--quoteo(post=377079:date=May 25 2006, 01:51 PM:name=nogray)--][div class=\'quotetop\']QUOTE(nogray @ May 25 2006, 01:51 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
try to add a ; after the code
$copy = "<?PHP";
[/quote]
My apologies for not adding it, but there is a ";" after the code.

I can replace that variable with any other information. However, <?, <?PHP and <% cuase problems when being used as variables. I tried slashes, trying to comment it out as I would double quotes, etc, but it's not working.

I believe I've worked a way around it. I wrote the template into a separate file and instead of dumping the code into a new file, I have the script copy the file from one location to another and rename it to what I need.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users