| | |
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: 91
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 |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code codingproblem cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select send server sessions sms snippet soap source space speed sql static structure syntax system table tutorial up-to-date update upload url validation validator variable video web wordpress xml youtube





