Hello,

I'm trying to do something I thought would be very simple. I need to display a "degree" symbol as part of my PHP output, and I can't figure it out. I'm trying to use the ASCII &deg code. If I try:

echo °

I get an error. If I try:

echo "&deg";

I simply display &deg on the screen. What am I missing? How can I display a degree symbol?

Thanks!

Recommended Answers

You need the ; for the htmlentity to be parsed so it's.

echo "°";
Jump to Post

Hi,
Try this

<?php
echo "Its 20";
?>
&deg
<?php
echo "F outside";
?>
Jump to Post

All 7 Replies

duh

echo "&deg;"

You need the ; for the htmlentity to be parsed so it's.

echo "&deg;";

Hi,
Try this

<?php
echo "Its 20";
?>
&deg
<?php
echo "F outside";
?>

I will give you one new idea.....:idea:

to show symbol degree....
Here are the fantastic steps...:icon_mrgreen:

1> on your key board you will see num lock key....
on num lock key....
2> wtite your php code....

<?php
echo "Its 20";
?>

3> press Alt + down arrow + 248 and leave it....

After this
Surprise.....for you...:icon_surprised:

4> You will see degree symbol...... :icon_smile:

<?php
echo "Its 20 °";
?>

How's the idea.....:icon_razz:

Why not do what is usually done in MS Word and make the letter o in superscript. So try the below code:

<?
echo "It is 20<sup>o</sup>C.";
?>

He already solved it with adding the ; on the end inside quotes.

problem is already solved...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.