Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8150801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:10:22+00:00 2026-06-06T15:10:22+00:00

I’m working on a PHP class that serves as a wrapper for the Memcached

  • 0

I’m working on a PHP class that serves as a wrapper for the Memcached class provided via a PECL extension. I am having difficulty handling a method that calls the get method. The third argument in the get method defaults to null and passes a variable by reference. I am having difficulties mirroring the functionality of the Memcached get method with my wrapper.

By using the Memcached class directly, the following occurs:

$m = new Memcached();
$m->addServer( '127.0.0.1', 11211 );

$m->add( 'my-key', 'my-value' );

$m->get( 'my-key', null, $cas_token );

var_dump( $cas_token ); // (float) 3212

The point here is that I can pass an uninitialized, null var to the get function and it works by setting the CAS token to that var, which can then later be accessed.

In my class, I want to offer the ability to use this CAS token with my wrapper method; however, I want the ability to do something different depending on whether the method is called with the third variable or not. I cannot find a way to differentiate whether the third variable has been explicitly called or not when I use the wrapper method. A skeleton of what I’m attempting follows:

class MyMemcached {

    ...

    public function get( $key, $cache_cb = NULL, &$cas_token = NULL ) {
        if ( is_callable( $cache_cb ) || ! is_null( $cas_token ) ) {
            $this->m->get( $key, $cache_cb, $cas_token );
        } else {
            // Do something differently
        }
    }
}

$myMemcached = new Memcached();
$myMemcached->addServer( '127.0.0.1', 11211 );

$myMemcached->add( 'my-key', 'my-value' );

$myMemcached->get( 'my-key', null, $cas_token );

var_dump( $cas_token ); // NULL

Again, in MyMemcached::get, I cannot distinguish between if a user calls it with a NULL var or not. Do you know of any way I can distinguish between these two events?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:10:24+00:00Added an answer on June 6, 2026 at 3:10 pm

    http://www.php.net/manual/en/function.func-num-args.php

    You can determine by this function whatever there was 2 or 3 arguments passed in function. If number is 3, than actual null value has been passed, and if not, there is only two parameters passed in function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.