| | |
Echo a Variable
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2007
Posts: 89
Reputation:
Solved Threads: 2
I've been echoing variables by simply typing "echo" then the variable. For instance:
This has been working just fine. I was watchign a tutorial and when he echoed his variable he put his in curly brackets. This is the example:
Did he do it like that because of the POSTS command? Was this necessary? Help me understand, please? Thanks
PHP Syntax (Toggle Plain Text)
<?php $name = "Me"; echo $name; ?>
PHP Syntax (Toggle Plain Text)
<?php $username = $_POST['username']; $password = $_POST['password']; echo "{username} : {$password}"; ?>
Did he do it like that because of the POSTS command? Was this necessary? Help me understand, please? Thanks
0
#2 Oct 13th, 2009
Its not needed there, there are a couple of uses for the braces, such as variable variables, but I believe the most common use is to include array vars in a string.
For example:
instead of this:
For example:
PHP Syntax (Toggle Plain Text)
echo "My name is {$_GET['name']}<br />";
PHP Syntax (Toggle Plain Text)
echo "My name is " . $_GET['name'] . "<br />";
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
![]() |
Similar Threads
- How do i echo a variable in a php mysql query ? (PHP)
- passing php variable into xml script (PHP)
- PHP Variable in mySQL query (PHP)
- echo not working (PHP)
- Repeat text from somewhere else in a document without actually writing it! (PHP)
- Pattern matching? (Shell Scripting)
- mysql date ALWAYS = 0000-00-00 00:00:00 (PHP)
- Help with simple shell script (Windows NT / 2000 / XP)
- paging & _POST variables (PHP)
- $variable inside quotes (PHP)
Other Threads in the PHP Forum
- Previous Thread: Reliable / Suitable refresh, redirect ?
- Next Thread: Profile user page
| Thread Tools | Search this Thread |
.htaccess action ajax apache api array auto beginner binary bounce broken cakephp checkbox class cms code cron curl database date display dynamic echo email error errorlog file files folder form format forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla limit link login loop mail malfunctioning masterthesis menu mlm mod_rewrite multiple mysql nodes oop paypal pdf php popup problem query radio ram random recursion reference regex remote return script search server sessions sms soap source space sql syntax system table tutorial unset update upload url validation validator variable video web websitecontactform xml youtube





