Solved

pointers to static methods

Posted on 2012-03-13
2
291 Views
Last Modified: 2012-03-14
Hi, I defined pointers to 3 different static methods

 if ($cond1)
   $crtrow = function () { return DD::cuctrowch(); };

 if ($cond2)
   $crtrow = function () { return DD::cuctrow(); };

 if ($cond3)
   $crtrow = function () { return DD::cuctrowp(); };


class DD
 static function  cuctrow($row)
 {

 }
 static function  cuctrow($row)
 {

 } 
..
..
}

Open in new window


each of those function requires a parameter. however when i call $crtrow($row)

i am getting an error that function

DD::cuctrow() requires parameter, which I am passing
0
Comment
Question by:Rozamunda
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37718792
My guess is that you are saying "function () ..." which means you aren't declaring that the anonymous function takes a parameter at all. Sure, the function that is being called in the body of that anonymous function does, but you have not provided a way for the anonymous function to receive a parameter.

In short, instead of "function ()..." try "function ($row)...".

...and you'll also need to pass that parameter.

e.g.

if ($cond3)
   $crtrow = function ($row) { return DD::cuctrowp($row); };

Open in new window

0
 
LVL 10

Accepted Solution

by:
Derokorian earned 500 total points
ID: 37719704
You could also use the use () method and referencing. Like so:
if ($cond1)
   $crtrow = function () use (&$row) { return DD::cuctrowch($row); };

Open in new window

See http://php.net/manual/en/functions.anonymous.php for more info
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
reverse engineer .sql from php files 11 54
Length of for loop to be dynamic 2 33
scan php uploads for viruses 5 27
PHP Underscores vs. Directory separators 5 29
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question