![]() |
Like in python you think you will be able to define argument....
In python I forget what its called by you can assign arguments by name for example:
Code:
test(name=blah) |
If I understand you correctly, you can do this in PHP already (kinda)
For example: PHP Code:
Alan |
No that doesn't work.
|
What problem do you experiance when using the code? I've tested the code above on PHP 5.2.5 and it works fine.
Can you explain more what you are trying to achieve? Alan |
Have you used python before?
Code:
def example(opt,opt2 = 0):Code:
function example($opt1,$opt2 = 'test') |
ahh, I see what you mean now. The only way you could achieve that in PHP at the moment is to lump all your arguments into an array and parse the array to your function:
PHP Code:
As far as I am aware there are no plans to introduce this form of argument handling in PHP 5.3 or 6 but if you really want to see it, you should post the idea to the php-internals mailing list to see what they think. Alan |
Alright :)
But seriously don't you think this is a perfect idea? For functions like: function textDecoration( $font, $size, $underlined = false, $strikethrough = false ); what if u wanted strikethrough and not underline? |
It would make like easier by not having to pad function calls:
PHP Code:
|
It is a good solution in Python, but if you want this in PHP you're good to go with arrays like Alan said.
Also the same thing could be used in Javascript for defining some atribute (Umm - Prototype - Code:
Effect.toggle( 'id', 'effect', {'duration':'1'} );Code:
function textDecoration( $font, $size, $underlined = false, $strikethrough = false );PHP Code:
If underlined specified - underline, if not - don't. I mean you get the picture. Hope I helped. Thanx to Alan :) |
| All times are GMT. The time now is 10:54 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0