Jump to content

Archived

This topic is now archived and is closed to further replies.

mslater

fwrite and <?PHP

Recommended Posts

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
[code]$copy = "<?PHP"[/code]

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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
[!--quoteo(post=376940:date=May 25 2006, 05:32 AM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ May 25 2006, 05:32 AM) [snapback]376940[/snapback][/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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
try to add a ; after the code
[code]
$copy = "<?PHP";
[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=377079:date=May 25 2006, 01:51 PM:name=nogray)--][div class=\'quotetop\']QUOTE(nogray @ May 25 2006, 01:51 PM) [snapback]377079[/snapback][/div][div class=\'quotemain\'][!--quotec--]
try to add a ; after the code
[code]
$copy = "<?PHP";
[/code]
[/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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.