I have a function like this:
function get_articles($cat=1,$numberposts=1);
it can be used:
get_articles(cat=4&numberposts=6);
//will display 6 posts from category 6
then I want to use that function within another function, like this:
function display_cat($new_cat=1,$new_num=1,$othercontent="" )
{
get_articles(cat=$new_cat&numberposts=$new_num)
.......
}
Can I pass function like this ? 5 1176
I have a function like this:
function get_articles($cat=1,$numberposts=1);
it can be used:
get_articles(cat=4&numberposts=6);
//will display 6 posts from category 6
You mean
get_articles(cat=4, numberposts=6);
yes?
then I want to use that function within another function, like this:
function display_cat($new_cat=1,$new_num=1,$othercontent="" )
{
get_articles(cat=$new_cat&numberposts=$new_num)
......
}
Can I pass function like this ?
I think you mean
get_articles($new_cat, $new_num);
And you're not passing a function, you're passing variables. You can't
pass functions in PHP. You could pass objects, but you don't need to
here.
I think you mean
get_articles($new_cat, $new_num);
And you're not passing a function, you're passing variables. You can't
pass functions in PHP. You could pass objects, but you don't need to
here.
Thank you very much for your reply.
here is exactly my code:
$article = get_articles(cat=4&numberposts=6);
// then I will extract data from $article
However, I want to pass 2 parametes cat and numberposts from another
function, so I must write another function:
function display_cat($new_cat=1,$new_num=1,$othercontent="" )
{
$article=get_articles(cat=$new_cat&numberposts=$ne w_num)
......
}
My purpose is want to pass $new_cat and $new_num from function
display_cat().
Is is possible ?
Please help me, thank you very much !
BabyBlue wrote:
I have a function like this:
function get_articles($cat=1,$numberposts=1);
it can be used:
get_articles(cat=4&numberposts=6);
//will display 6 posts from category 6
Wrong group?
This is not PHP; the syntax is wrong.
For the correct PHP syntax read the manual: http://www.php.net/manual/en/functions.arguments.php
--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
..oO(BabyBlue)
>here is exactly my code:
$article = get_articles(cat=4&numberposts=6);
Should be
$article = get_articles(4, 6);
>However, I want to pass 2 parametes cat and numberposts from another function, so I must write another function:
function display_cat($new_cat=1,$new_num=1,$othercontent="" )
{
$article=get_articles(cat=$new_cat&numberposts=$ne w_num)
Should be
$article = get_articles($new_cat, $new_num);
}
Micha
BabyBlue wrote:
I have a function like this:
function get_articles($cat=1,$numberposts=1);
it can be used:
get_articles(cat=4&numberposts=6);
//will display 6 posts from category 6
then I want to use that function within another function, like this:
function display_cat($new_cat=1,$new_num=1,$othercontent="" )
{
get_articles(cat=$new_cat&numberposts=$new_num)
......
}
Can I pass function like this ?
No, you are incorrect. You would call it with:
get_articles(4, 6);
"cat=4&numberposts=6" is strictly an HTML implementation. It's not used
within functions like this.
So in your display_cat function, you would call it with
get_articles($new_cat, $numberposts);
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
================== This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: J.R. |
last post by:
Hi folks,
The python can only support passing value in function call (right?), I'm
wondering how to effectively pass a large parameter, such as a large list or
dictionary?
It could achieved...
|
by: zipher |
last post by:
After searching through comp.lang.python and the web regarding
metaclasses, I could not find an example for customing classes using
metaclass parameters.
I want to be able to create a class at...
|
by: John Miles |
last post by:
Hi --
This is a bit of an implementation-specific problem, but I'd like to
post it here to see if there's a general answer within the auspices of
the language.
I'm developing a high(er)-level...
|
by: Pavils Jurjans |
last post by:
Hallo,
I have been programming for restricted environments where Internet Explorer
is a standard, so I haven't stumbled upon this problem until now, when I
need to write a DOM-compatible code.
...
|
by: Derek |
last post by:
I have an aspx page where I use a reversebind and
templates to edit the entire datagrid at one time. I
added a textbox and button to change the parameter
criteria and then rerun the databind2...
|
by: Ekim |
last post by:
hy,
I've got a question according default parameters of functions that are
accessed from different files:
---- logging.h ----
void LogTrace(const char* errorLocation, const char* errorInfo =...
|
by: pamelafluente |
last post by:
Hi guys,
In the past I have used several time optional parameters in my
function.
But Now I am more inclined to think that they are more dangerous than
useful, and probably better to be...
|
by: AxleWacl |
last post by:
Hi,
The below error is what I am receiving. The code im using is below the error, for the life of me, I can not see where any parameter is missing.....
Server Error in '/FleetcubeNews'...
|
by: Harlequin |
last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| | |