I have a problem that I hope someone can help me out with. I need to write a variable like the one below to a file. Currently, I am trying to do this similar to as shown below, to no avail:
The code above simply writes "Bob.html" in the file without the directory path. Granted, the backslash(\) is generally used for other purposes in PHP. So, I changed them to foward slashes with no luck either.
If I change
to
It works fine.
Is there a way to pass the directory path via a variable? Similar to my first attempt?
Thanks!
IamStang
Code:
$dirPath = "C:\script_pages\myPHPscript\";
$userName = "Bob"; //Could be anything.
$EmpHTMLFile = "my_data.txt";
$Emp_html = fopen($EmpHTMLFile, "a");
fwrite($Emp_html, $dirPath."/".$userName.".html\n");
fclose($Emp_html);
The code above simply writes "Bob.html" in the file without the directory path. Granted, the backslash(\) is generally used for other purposes in PHP. So, I changed them to foward slashes with no luck either.
If I change
Code:
fwrite($Emp_html, $dirPath."/".$userName.".html\n");
Code:
fwrite($Emp_html, "C:/script_pages/myPHPscript/".$userName.".html\n");
Is there a way to pass the directory path via a variable? Similar to my first attempt?
Thanks!
IamStang