karthikanov24 Posted October 31, 2009 Share Posted October 31, 2009 hi <?php echo "<td width=\"$columnWidth%\" align=\"center\"><a href=\"" . $_SERVER['PHP_SELF'] . "?c=$catId&p=$pd_id" . "\"><img src=\"$pd_thumbnail\" border=\"0\"><br>$pd_name</a><br>Price : $pd_price"; ?> In the above line of php code, whats the function of those slashes (\) ..? why the slash is inside the double quotes,which is after c=$catID&p=$pd_id". thanks karthikanov24 Quote Link to comment https://forums.phpfreaks.com/topic/179716-tag-inside-php/ Share on other sites More sharing options...
cags Posted October 31, 2009 Share Posted October 31, 2009 All strings are delimited (surrounded) by quotes. These can either be single quotes or double quotes. Whichever type you use, if you then wish to use that type of quote inside the string you need to escape them, otherwise PHP will think that is the end of the string. Escaping is done using a backslash. . "?c=$catId&p=$pd_id" . "\"> The first double quote starts a string, the second one (after $pd_id) closes that string, the fullstop concatinates another string. The thrist double quote starts this string, then we need to output a double quote as part of the string (as a closing delimiter for the href attribute) so it is escaped. That particular code is a little odd in the fact that it uses a combination of techniques, but it's still correct. Quote Link to comment https://forums.phpfreaks.com/topic/179716-tag-inside-php/#findComment-948254 Share on other sites More sharing options...
karthikanov24 Posted November 1, 2009 Author Share Posted November 1, 2009 hi in the following part of the above posted code, <a href=\''".$_SERVER'PHP_SELF']."?=$catId&p=$pd_id". "\"> If the double quotes are replaced by single quotes as follows,its not working... <a href=\'' ' .$_SERVER'PHP_SELF'].'?=$catId&p=$pd_id'. '\"> or <a href=\' ".$_SERVER'PHP_SELF']."?=$catId&p=$pd_id". "\'> or <a href=\' ' .$_SERVER'PHP_SELF'].'?=$catId&p=$pd_id'. '\'> why it so...? could you explain me with an example <a href> tag...please.. thanks karthikanov24 Quote Link to comment https://forums.phpfreaks.com/topic/179716-tag-inside-php/#findComment-948571 Share on other sites More sharing options...
avvllvva Posted November 1, 2009 Share Posted November 1, 2009 <?php echo "<a href='".$_SERVER['PHP_SELF']."?c=$catId&p=$pd_id'>link</a>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/179716-tag-inside-php/#findComment-948593 Share on other sites More sharing options...
karthikanov24 Posted November 1, 2009 Author Share Posted November 1, 2009 hi I tried to find the urls relating to the questions that i posted above by typing , "<td width=\"$columnWidth%\" align=\"center\"><a href=\"" . $_SERVER['PHP_SELF'] . "?c=$catId&p=$pd_id" . "\"> in the google search bar in google website...... but i did'nt get the correct url that explains me these things told by you.. So could you say me,what words should be typed in google search,to get the correct urls that deals with my above question....please...?? and thanks for your answers.. karthikanov24 Quote Link to comment https://forums.phpfreaks.com/topic/179716-tag-inside-php/#findComment-948679 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.