Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
| Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 27th, 2004, 07:56 PM
Authorized User
 
Join Date: Aug 2003
Location: Coeur d\'Alene, ID, USA.
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tachyon
Default using echo command to display "$"

This is probably a pretty easy question. When you are using the echo command to display text in a browser window it automatically interprets $ as an indicator of a variable. How do you get it to display "$" in the browser window? How do you override that automatic interpreting?

__________________
An overworked Web Developer who\'s expected to know everything yet given time to study nothing.
  #2 (permalink)  
Old February 27th, 2004, 08:09 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Use a backslash to escape the dollar sign like you would for quotes or other special characters.

echo "\$10.00";

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
  #3 (permalink)  
Old February 27th, 2004, 09:03 PM
Authorized User
 
Join Date: Aug 2003
Location: Coeur d\'Alene, ID, USA.
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tachyon
Default

Thanks! I was hoping I wouldn't have to pour through online searches. :)

  #4 (permalink)  
Old March 1st, 2004, 09:54 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Alternatively, use a single-quoted string.

echo '$10.00';

PHP does not perform variable substitutions in single-quoted strings.

http://www.php.net/types.string


Take care,

Nik
http://www.bigaction.org/


Similar Threads
Thread Thread Starter Forum Replies Last Post
search data echo urbanaccess Access 7 January 23rd, 2007 10:54 AM
I need a echo wizard Anne1 PHP How-To 1 December 16th, 2006 04:20 AM
echo "\n" problem jun99 PHP How-To 4 November 29th, 2005 01:01 PM
echo "\n" problem jun99 Beginning PHP 0 November 27th, 2005 05:12 PM
new need help displaying echo $SESSION['authuser'] skafreak121 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 11 June 13th, 2005 01:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.