Asked 4 years, 3 months ago Viewed 616 times I try to put image size in image src tag, but it still does not work. The image can be displayed fine.
Nigel Ren 54.6k11 gold badges39 silver badges53 bronze badges asked Jun 12, 2018 at 6:13 4 You can use getimagesize() function http://php.net/manual/en/function.getimagesize.php to fetch image size
answered Jun 12, 2018 at 6:20 Bhumi ShahBhumi Shah 8,9617 gold badges58 silver badges96 bronze badges 3 Not the answer you're looking for? Browse other questions tagged php or ask your own question.I am echoing an image which works fine, but then i want to set how big it needs to be, and I just can't seem to get the syntax right. This is what I have:
What am I doing wrong? If I remove the height and width it works fine. cyborg86pl 2,6082 gold badges26 silver badges44 bronze badges asked Apr 22, 2014 at 15:43 0 You are mixing single and double quotes. So you get a syntax error. This works:
If you like to output double quotes you have to escape:
Or you switch to cover the string in single quotes:
answered Apr 22, 2014 at 15:46 theHackertheHacker 3,9341 gold badge18 silver badges30 bronze badges try changing double quotes into single quotes for these attributes
since double quotes are actually delimiting the PHP string. Optionally you may instead escape the double quotes like so
but this syntax is less readable and more error prone (not recommended) answered Apr 22, 2014 at 15:45 Fabrizio CalderanFabrizio Calderan 117k25 gold badges164 silver badges168 bronze badges ok its here
answered Apr 22, 2014 at 15:45 4 You can uses variables inside double quotes, like this:
answered Apr 22, 2014 at 15:50 Pedro LobitoPedro Lobito 88.2k29 gold badges238 silver badges256 bronze badges Sometimes the way that you're using causes to errors if you don't do it properly.Therefore you can try this way also.
if you're using this inside a loop,you can do like this.
Hope this helped to you. answered Apr 22, 2014 at 15:52 CodeCanyonCodeCanyon 9191 gold badge11 silver badges35 bronze badges Not the answer you're looking for? Browse other questions tagged php html syntax or ask your own question. |