| | |
Passing in Arguments
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
Good afternoon all,
I'm at the beginning stages of learning PHP. I'm trying to understand passing in functions. I have a video lesson so I can see what is being explained but for some reason i am still not getting it.
Can someone possibly explain it in a way that I would? This will also help me better understand ActionScript 3.0 Thanks.
I'm at the beginning stages of learning PHP. I'm trying to understand passing in functions. I have a video lesson so I can see what is being explained but for some reason i am still not getting it.
PHP Syntax (Toggle Plain Text)
<?php function hello($word) { echo "Hello {$word}!<br/>"; } hello("Daniweb"); ?>
0
#2 Oct 8th, 2009
What exactly don't you understand? You have a function 'hello' that takes 'name' as a parameter. Any time you call hello and pass it a value, in this case Daniweb it will use that value as the value of the parameter name.
PHP Syntax (Toggle Plain Text)
function hello($name) { echo 'Hello, ' . $name; } hello('Daniweb'); // is exactly like saying echo 'Hello, ' . 'Daniweb'; // since the value of $name becomes 'Daniweb'
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
•
•
Join Date: Jul 2007
Posts: 91
Reputation:
Solved Threads: 2
•
•
•
•
What exactly don't you understand? You have a function 'hello' that takes 'name' as a parameter. Any time you call hello and pass it a value, in this case Daniweb it will use that value as the value of the parameter name.
PHP Syntax (Toggle Plain Text)
function hello($name) { echo 'Hello, ' . $name; } hello('Daniweb'); // is exactly like saying echo 'Hello, ' . 'Daniweb'; // since the value of $name becomes 'Daniweb'
Last edited by Reliable; Oct 8th, 2009 at 3:34 pm. Reason: further information
![]() |
Similar Threads
- Syntax for running a .vbs with arguments (Visual Basic 4 / 5 / 6)
- Need Help about Passing Pointers in a Function, and Reflecting any changes. (C++)
- Passing argument to boost thread with boost bind (C++)
- passing parameters to .exe file using C++ (C++)
- command line arguments (Python)
- Problem with interpretation of the command line arguments in the script (Shell Scripting)
- Command-line Arguments. (C++)
- Passing arguments to jsp file (Java)
- Preparing for an interview and need some questions answered (C)
Other Threads in the PHP Forum
- Previous Thread: Info on http uploads?
- Next Thread: generate a PDF and send as attachment
Views: 191 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date datepart directory display download dynamic echo email error file files folder form forms function functions google head href htaccess html image include insert integration ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql oop parse password paypal pdf php problem query radio random recursion regex remote script search select seo server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube






