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? Quote 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. Quote 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"; Quote 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 Quote 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? Quote 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? Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.