| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Member | 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 | A basic example of a function that accepts 2 arguments: PHP Code: 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 | Quote:
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! | |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |