Hi all, I am currently attempting to add some html inline styling to php, but all I seem to get is the error: The original line is: echo htmlentities($data[0]); PHP: What I currently have (which does not work) is: echo "<p style=\"width:200\">"htmlentities($quote)"</p>"; PHP: Any help would be gratefully appreciated!
Thank you. That did get rid of the error and now displays the quote, but the actual style is not presented (it is not 200px wide - still the length of the window).
You need to be careful what you use when you output data on the screen, you can do it using apostrophes (') or quotes ("). There is a difference between them... echo '<p style="width:200px">PHP\'s the best</p>'; PHP: or echo "<p style=\"width:200px\">PHP's the best</p>"; PHP: You have to make sure you escape the proper character. In your example, you should do: echo '<p style="width:200px">' . htmlentities($quote) . '</p>'; PHP: aXe
Any time you put 2 things together you have to use the concat operator which is the period " . " Also as stated above, when echoing HTML tags it's very important to use different types of quotes: ie echo "<a href='www.google.com'>Google</a>"; Whether you use " or ' to enclose either your php statement or your href does not matter. It's just important to never use the same one in two different cases as above, else php will get confused and not run.
This is the basic problem php developer can face at their starting phase. But no problem friend here is the solution. Here are the two ways to do this: 1) Embed html in php Tip: always use single quote (') if you are embed you r html in php. 2) make html and php separate Personally I prefer the second method, but it can be used based on situation. Hope this helps. Avinash