3

in a wordpress php script, I have the following:

echo '<div class="slide-media">' . $slide_media . 
     '</div><!--/.slide-media-->' . "\n";               }

I want to see the contents of what is inside $slide_media variable. Basically, so I can add a link to the image.

Is there a variable to plain text function? Thanks

0

5 Answers 5

5

If you're outputting raw HTML to a HTML document (and you want it shown as <b>text</b> instead of text), you can use htmlentities($string):

htmlentities($slide_media);

If your string is UTF8, you might have to specify this (if your PHP version is 5.4+, you don't have to specify UTF-8, as it's default):

htmlentities($slide_media, ENT_QUOTES, "UTF-8");

You can also strip all HTML tags from the variable by using strip_tags($string):

strip_tags($slide_media);
Sign up to request clarification or add additional context in comments.

Comments

3

To see what is within a variable (maybe it is in array, an object or something else) use print_r($slide_media); or var_dump($slide_media);

Comments

1

I would do:

echo '<pre>' . var_export($slide_media, true) . '</pre>';

Or maybe

echo '<pre>' . var_export(array_map('htmlentities', $slide_media), true) . '</pre>';

If $slidemedia is an array with html content.

Comments

0

print_r Prints human-readable information about a variable

Comments

0
<?php print_r($slide_media); ?> 

should do the trick for you.

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.