954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

add double quotation sign in echo.. Help...

echo ("<a href=foldername/".$file.">".$file."</a>"."");

and there

$file = readdir($handle);


in that case $file is a folder name with space.. So I have to put double quotation after href=. But it doesnt printing that double quotation. The link I am getting is only the folder name's first thing before space. So the link Generating is wrong...

Please help me..

kirtan_thakkar
Junior Poster in Training
79 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

Hi, there are several methods of printing double quotes, two of them are:

1) Using single quotes:
echo 'Example';

2) Escaping in double quotes:
echo "Example";

I'd recommend sticking to single quotes since its more readable and has better micro performance because it doesn't interpolate variables as double quotes do, that is -

$x = 42;
echo "My value: $x"; // prints: My value: 42
echo 'My value: $x'; // prints: My value: $x

GoatHunter
Newbie Poster
8 posts since Jun 2010
Reputation Points: 10
Solved Threads: 1
 

Hi, there are several methods of printing double quotes, two of them are:

1) Using single quotes: echo 'Example';

2) Escaping in double quotes: echo "Example";

I'd recommend sticking to single quotes since its more readable and has better micro performance because it doesn't interpolate variables as double quotes do, that is -

$x = 42; echo "My value: $x"; // prints: My value: 42 echo 'My value: $x'; // prints: My value: $x

echo ('<a href="quotations/$file">'.$file.'</a>');


I have tried this but getting this link
"foldername/$file"

Help..

kirtan_thakkar
Junior Poster in Training
79 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

True because single quote don't interpolate variables, you'll have to use the concat operator (dot) :


echo '' . $file . '
';

GoatHunter
Newbie Poster
8 posts since Jun 2010
Reputation Points: 10
Solved Threads: 1
 

True because single quote don't interpolate variables, you'll have to use the concat operator (dot) :

echo '' . $file . '
';


Now not getting the first name(before space)
Getting this only..
"quotations/"

kirtan_thakkar
Junior Poster in Training
79 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

right my mistake it should be
echo '' . $file . '
';

I misplaced the second double quote.

GoatHunter
Newbie Poster
8 posts since Jun 2010
Reputation Points: 10
Solved Threads: 1
 

right my mistake it should be echo '' . $file . '
';

I misplaced the second double quote.


Hey thanks...
It works..

kirtan_thakkar
Junior Poster in Training
79 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: