ghurty Posted January 25, 2010 Share Posted January 25, 2010 What would the proper way of writing: $tofile = "/dialer/$calldate/" So that you can use the variable in the path? Link to comment https://forums.phpfreaks.com/topic/189698-what-would-the-proper-way-of-writing-tofile-dialercalldate/ Share on other sites More sharing options...
oni-kun Posted January 25, 2010 Share Posted January 25, 2010 What would the proper way of writing: $tofile = "/dialer/$calldate/" So that you can use the variable in the path? You're using it the right way, or you can as well do this: $basepath = '/dialer/'; $tofile = $basepath . $calldate; Either way is fine. Link to comment https://forums.phpfreaks.com/topic/189698-what-would-the-proper-way-of-writing-tofile-dialercalldate/#findComment-1001137 Share on other sites More sharing options...
RussellReal Posted January 25, 2010 Share Posted January 25, 2010 note1: Using variables in strings are only possible in evaluating quotes (") like you have in your example. Using them inside of non-evaluating quotes (') will just output the variable name. note2: Using curly braces to tell the php interpreter the variable name is often the better option, because you MAY have a variable named $abc and want to use it in a string directly next to another VALID variable name character.. for example $abc = "123"; $e = "$abc456"; to avoid the variable being interpreted as $abc456 you'd surround the variable inside the string with curly braces. $abc = "123"; $e = "{$abc}456"; Link to comment https://forums.phpfreaks.com/topic/189698-what-would-the-proper-way-of-writing-tofile-dialercalldate/#findComment-1001139 Share on other sites More sharing options...
ghurty Posted January 25, 2010 Author Share Posted January 25, 2010 Thank you Link to comment https://forums.phpfreaks.com/topic/189698-what-would-the-proper-way-of-writing-tofile-dialercalldate/#findComment-1001142 Share on other sites More sharing options...
oni-kun Posted January 25, 2010 Share Posted January 25, 2010 note1: Using variables in strings are only possible in evaluating quotes (") like you have in your example. Using them inside of non-evaluating quotes (') will just output the variable names And where does he use single quotes? Link to comment https://forums.phpfreaks.com/topic/189698-what-would-the-proper-way-of-writing-tofile-dialercalldate/#findComment-1001145 Share on other sites More sharing options...
RussellReal Posted January 25, 2010 Share Posted January 25, 2010 note1: Using variables in strings are only possible in evaluating quotes (") like you have in your example. Using them inside of non-evaluating quotes (') will just output the variable names And where does he use single quotes? And where in that quote do I say he uses single quotes? Link to comment https://forums.phpfreaks.com/topic/189698-what-would-the-proper-way-of-writing-tofile-dialercalldate/#findComment-1001151 Share on other sites More sharing options...
SadZer Posted February 2, 2010 Share Posted February 2, 2010 I am so lucky that I so this discussion. Now I know that the proper way of writing it. This is very useful this time. This is the best day I ever had. Link to comment https://forums.phpfreaks.com/topic/189698-what-would-the-proper-way-of-writing-tofile-dialercalldate/#findComment-1005283 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.