I have a function that has two arguents, however depending on the value
of the first argument, the second one may or may not be needed. If I
only input the first argument when calling the function, PHP returns a
warning. many built in php functions have optional arguments, is there a
way to make arguments in user defined functions optional as well?
Thanks. 2 17739
On Wed, 17 Aug 2005 14:27:45 -0700, Exyle <us**********@r eg.exyled.net> wrote: is there a way to make arguments in user defined functions optional http://uk2.php.net/manual/en/functions.arguments.php
--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Exyle schrieb: I have a function that has two arguents, however depending on the value of the first argument, the second one may or may not be needed. If I only input the first argument when calling the function, PHP returns a warning. many built in php functions have optional arguments, is there a way to make arguments in user defined functions optional as well?
Thanks.
You have to give the second argument a default value
function foo($arg1,$arg2 =NULL)
then the function can be called without $arg2
hih
Jo This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: JT |
last post by:
how can i declare a function that will accept an optional parameter?
something like:
function newFunc(strValue1, strValue2) --where strValue2 is optional.
thanks much.
|
by: Ken Post |
last post by:
Hi All:
I've read a whole slew of posts about creating temp tables using stored
proceedures to get the crosstab ability, but I'm wondering if, for this
specific case, there might be a more efficient way.
What makes this question different from the others that I've read is
that I'm using user defined functions, not tables. I actually think
that I've got the crosstab thing down, it's just passing the parameter
to the 2nd udf that's...
|
by: David Emme |
last post by:
Access 97
I have a number of SELECT statements which contain references to
user-defined VBA functions. These typically work as expected, but
occasionally, on one user's machine or another, produce a "function not
defined" message when the SELECT statement is executed, even having
previously worked on that machine.
What can I do to correct this difficulty when it occurs? What do I need
to know about user-defined functions in SELECT...
|
by: ad |
last post by:
Does C#2.0 support optional parameters like VB.NET:
Function MyFunction(Optional ByVal isCenter As Boolean = False)
|
by: Winshent |
last post by:
I want to pass optional arguments to build up varios strings, is this
possible?
look at arrTBL(1,3) in the code below:
===========================================
Public Function arrTBL(Optional ByVal DataSetName As String = "") As
String(,)
Dim DSN As String = DataSetName
| |
by: karthi |
last post by:
hi,
I need user defined function that converts string to float in c.
since the library function atof and strtod occupies large space in
my processor memory I can't use it in my code.
regards,
Karthi
|
by: Naya |
last post by:
Hi.
I am trying to write a program that asks for the wholesale cost of an
item and its markup percentage, and displays the retail price.
Well, I did that the regular way, but...
My instructions require for me to:
Create a function that accepts the wholesale cost and markup
percentage as arguments
|
by: chromis |
last post by:
Hi,
I've been trying to implement a more OOP oriented approach to dealing with user security on one of my websites, and I am trying to validate the user against an array of roles, however I am struggling with a type error:
The argument ROLES passed to function setRoles() is not of type array.
If the component name is specified as a type of this argument, the reason for this error might be that a definition file for such component...
|
by: PatrickMinnesota |
last post by:
I've been reading the docs and looking for an answer and seem stuck.
I'm either not looking in the right places or not understanding what
I'm reading.
I have a bunch of functions. I want to put them in a list. Then I
want to pass that list into another function which does some setup and
then loops through the list of passed in functions and executes them.
Some of them need arguments passed in too.
Can someone point me to where to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |