List Info

Thread: Checking for empty object




Checking for empty object
country flaguser name
United States
2007-07-30 05:44:07
Hi,

does anyone know how I can check if an object is empty?

I want to do something like this:

if (empty($this->orders)) {
	echo 'No jobs currently in this view.';
}

...but this doesn't work.

Thanking you,
Con


--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.

For information or project assistance please visit :
http://www.360psg.com

You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHPgooglegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---


Re: Checking for empty object
user name
2007-07-30 12:26:44
You can try

if ($this->;orders == NULL || $this->orders == "") {
       ; echo 'No jobs currently in this view.';
}

On 7/30/07, conmulligan < conmulligangmail.com">conmulligangmail.com> wrote:

Hi,

does anyone know how I can check if an object is empty?

I want to do something like this:

if (empty($this->orders)) {
 &nbsp; &nbsp;   ; echo 'No jobs currently in this view.';
}

...but this doesn't work.

Thanking you,
Con






--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.

For information or project assistance please visit :
http://www.360psg.com

You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
To post to this group, send email to Professional-PHPgooglegroups.com
To unsubscribe from this group, send email to Professional-PHP-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---

Re: Checking for empty object
country flaguser name
United States
2007-07-31 03:29:54
recheck php.net for the function empty. copy that code, then
replace
the variables. i sometimes find really careless mistakes
this way.


--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.

For information or project assistance please visit :
http://www.360psg.com

You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHPgooglegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---


Re: Checking for empty object
country flaguser name
United States
2007-07-31 06:13:37
maybe, you can try this:

if ( ! $this->orders )
{
     echo 'No jobs currently in this view.';
}

On Jul 30, 7:44 am, conmulligan <conmulli...gmail.com> wrote:
> Hi,
>
> does anyone know how I can check if an object is
empty?
>
> I want to do something like this:
>
> if (empty($this->orders)) {
>         echo 'No jobs currently in this view.';
>
> }
>
> ...but this doesn't work.
>
> Thanking you,
> Con


--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.

For information or project assistance please visit :
http://www.360psg.com

You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHPgooglegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---


Re: Checking for empty object
country flaguser name
United States
2007-07-31 13:36:09
Think better to use next function:

function not_null($value) {
    $res = false;
    if (is_array($value)) {
      if (sizeof($value) > 0) {
        $res = true;
      }
    } else {
      if (($value != '') && ($value != 'NULL')
&&
(strlen(trim($value)) > 0)) {
        $res = true;
      }
    }
    return $res;
  }

if(!not_null($this->orders)) {
   echo 'No jobs currently in this view.';
}

On Jul 30, 1:44 pm, conmulligan <conmulli...gmail.com> wrote:
> Hi,
>
> does anyone know how I can check if an object is
empty?
>
> I want to do something like this:
>
> if (empty($this->orders)) {
>         echo 'No jobs currently in this view.';
>
> }
>
> ...but this doesn't work.
>
> Thanking you,
> Con


--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.

For information or project assistance please visit :
http://www.360psg.com

You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHPgooglegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---


[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )