Jump to content

What would the proper way of writing: $tofile = "/dialer/$calldate/"


ghurty

Recommended Posts

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.

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";

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?

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?

Archived

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

×
×
  • 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.