| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Mar 2006 Location: new jersey
Posts: 92
![]() | PHP NEWB Question I am havbing trouble understanding the concepts of function arugments and multiple arguments Could someone explain the meaning of them for me please. Are they variables that function can only use? Or are they placeholders for when the function is excuted? I am very new to php.(as-if you cant tell.) |
| |
| | #2 (permalink) |
| NamePros Regular Join Date: Feb 2006
Posts: 528
![]() ![]() ![]() ![]() | A basic example of a function that accepts 2 arguments: PHP Code: ????: NamePros.com http://www.namepros.com/programming/210263-php-newb-question.html To use this, you would call it like this: echo my_math_function(5, 5); should ouput: 10 Regards, Peter
__________________ ILance - Enterprise Auction Software : As Seen on CNN & Fox News - View Online Demo - PHP/MySQL - SEO ready | 100% Customizable! |
| |
| | #5 (permalink) | ||||
| NamePros Regular Join Date: Feb 2006
Posts: 528
![]() ![]() ![]() ![]() |
Also, keep in mind you can have dummy arguments in place without having to use them: Check it out: function add_something($arg1, $arg2, $arg3 = '', $arg4 = '') { ... } With that above, you are telling this function that you will always use argument $arg1 and $arg2 but $arg3 and $arg4 may or may not be used (notice how I assigned dummy blank values beside them? Here is a perfect example: PHP Code: or you may need this: $result = do_math(5, 2, 'add');
__________________ ILance - Enterprise Auction Software : As Seen on CNN & Fox News - View Online Demo - PHP/MySQL - SEO ready | 100% Customizable! | ||||
| |