Jump to content

Recommended Posts

Help!  This is doing my head in - the following writes the correct config file data to a text file but I need the variable encapsulated in quotes for it to work.

 

$Data = '$htURL = ' . $serverpath . "\r\n";

fwrite($Handle, $Data);

 

Running out of time and lose the will on this one....

 

Link to comment
https://forums.phpfreaks.com/topic/196891-help-with-quotes-in-fwrite-command/
Share on other sites

Help!  This is doing my head in - the following writes the correct config file data to a text file but I need the variable encapsulated in quotes for it to work.

 

$Data = '$htURL = ' . $serverpath . "\r\n";

fwrite($Handle, $Data);

 

Running out of time and lose the will on this one....

 

You didn't ask a question

"I need the variable encapsulated in quotes for it to work."

 

I found the right format through trial and error:-

$Data = '$htURL = ' . "'" . $serverpath . "';\r\n";

 

However, it appears that I can't write a text file to the web server/host due to permission restrictions.

 

I've ran out of time on the assignment I'm doing so will just explain the documentation to my tutor how you change the config text file manually.

 

 

"I need the variable encapsulated in quotes for it to work."

 

I found the right format through trial and error:-

$Data = '$htURL = ' . "'" . $serverpath . "';\r\n";

 

However, it appears that I can't write a text file to the web server/host due to permission restrictions.

 

I've ran out of time on the assignment I'm doing so will just explain the documentation to my tutor how you change the config text file manually.

 

1) That's not a question still...

2) Assuming you mean "How do I encapsulate the variable in quotes"

There is no mention of what variable. There are 4 variables in the code you presented.

Sorry, you are quite correct.  The last of the two variables needed to be 'variable" so that the text file would look like this:-

 

$myvar1 = 'varvalue1';

$myvar2 = 'varvalue2';a

$myvar3 = 'varvalue3';

 

I sorted it in the end but have had to abandon it due to the permission problem - no time left for this part.

Single quotes will write the dollar symbol without needing for escaping. You can do this as well:

$content = "Some content."
$variable = "\$variable = $content"

 

And as for your permissions, it's as simple as opening up your FTP client and CHMODding the file/folder to 755/777 permissions to be able to write to the folder.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.