Re: Proposal: new extension of selinux
| From: | KaiGai Kohei | Date: | Fri, 27 Feb 2009 06:17:51 +0000 |
| Subject: | Re: Proposal: new extension of selinux | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-6170@lists.php.net to get a copy of this message | ||
KaiGai Kohei wrote:
> I have a question about interface of PHP function.
>
> Is it a right manner to consider 'false' as an error condition
> on a function which returns string?
>
> For example, I defined the following wrapper functions:
> string selinux_getfscreatecon(void)
>
> It returns a security context for a new filesystem object in text
> representation, if it is explicitly configured. A process does not
> have this context in the default, so this function returns an empty
> string in most cases.
> However, we have to consider a possibility system returns an error
> status. This functions returns 'false' on errors.
>
> My point is whether we can discriminate between an empty string
> and a false value, or not. If inappropriate, it is necessary to
> design API specifications for them again. :(
>
> | $ php -r 'if ("" == false) { echo "T\n"; } else { echo
> "F\n"; }'
> | T
> | $ php -r 'if (is_string("")) { echo "T\n"; } else { echo
> "F\n"; }'
> | T
> | $ php -r 'if (is_string(false)) { echo "T\n"; } else { echo "F\n";
> }'
> | F
>
> Hmm...
A few folks suggested me in private message, to use "===" operator.
It can resolve this matter.
Thanks,
--
OSS Platform Development Division, NEC
KaiGai Kohei <kaigai@ak.jp.nec.com>