0

Hello i am newbie in php I am having a simple php error I did google. but wasnt able to figure out the exact keywords

 <?php
 $vtext="<img alt="" src="/wp-content/themes/9GAG/images/smileynearvote.JPG" style="width: 15px; height: 17px; " />";
 ?>

This is how i call it

 <?php echo $vtext ?>

But when i use this i get an Internal server Error

i did google only founded that how to create an image with php

but didnt find how to use it string

My cms is wordpress

2 Answers 2

2

You need to escape your " (double quotes) or enclose the entire string in ' single quotes:

 $vtext = '<img alt="" src="/wp-content/themes/9GAG/images/smileynearvote.JPG" style="width: 15px; height: 17px; " />';

I encourage you to read more about Strings in PHP.

Note: This may not be the only error. When asking about errors you should always post the full error message and the offending line and the line above it.

Sign up to request clarification or add additional context in comments.

Comments

1

You have to escape the " in your string

$vtext="<img alt=\"\" src=\"/wp-content/themes/9GAG/images/smileynearvote.JPG\" style=\"width: 15px; height: 17px; \" />";

Read more http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.