Jump to content

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


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?

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.