SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist GeekSupport's Avatar
    Join Date
    May 2002
    Location
    Southern California
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    empty() for function returns?

    is there a built-in that checks if a function return is empty?

    ex:
    PHP Code:
    if (empty_return($obj->get_errors())
    {
         echo 
    'no errors';

    for now, i'm using
    PHP Code:
        // checks if the return is empty (used for functions like empty() is for $vars
        
    function empty_return($return)
        {
            return empty(
    $return);
        } 

  2. #2
    SitePoint Enthusiast press711's Avatar
    Join Date
    Apr 2003
    Location
    gold coast
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should be able to place the function directly inside the empty. e.g. empty(substr($test,4,2))

    Then again i might be wrong
    ---------------


  3. #3
    SitePoint Evangelist GeekSupport's Avatar
    Join Date
    May 2002
    Location
    Southern California
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by press711
    You should be able to place the function directly inside the empty. e.g. empty(substr($test,4,2))

    Then again i might be wrong
    thanks, but according to php.net

    Note: empty() only checks variables as anything else will result in a parse error. In otherwords, the following will not work: empty(addslashes($name)).

  4. #4
    Non-Member Icheb's Avatar
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    1,474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just assign a function's output to a variable and check that variable for being empty or not.

  5. #5
    SitePoint Evangelist GeekSupport's Avatar
    Join Date
    May 2002
    Location
    Southern California
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Icheb
    Just assign a function's output to a variable and check that variable for being empty or not.
    yeah, i was going to do that but hoped there was a way to do it in-line

  6. #6
    SitePoint Enthusiast press711's Avatar
    Join Date
    Apr 2003
    Location
    gold coast
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for that.

    In that case I agree with Icheb.
    ---------------



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •