[OWASP_PHPSEC] Namespace

rahul chaudhary rahul300chaudhary400 at gmail.com
Sun Jul 28 14:59:27 UTC 2013


About what Abbas said, If my current namespace is PHPSEC, PHP must look
into the namespace and must find a function called time() defined under
PHPSEC.

But for that to happen, I have to write     require_once("time.php");
in every file where I have to use it.

My question is that can I somehow not write the above line and still use
the \phpsec\time() function ???

And as Sven said, this only works for classes i.e I can use classes from
anywhere without using to include them in the current file.


On Sun, Jul 28, 2013 at 9:37 AM, Abbas Naderi <abiusx at owasp.org> wrote:

> why would it break? its compatible with PHP time function. Extra arguments
> to php functions are simply ignored.
> -A
> ______________________________________________________________
> *Notice:** *This message is *digitally signed*, its *source* and *
> integrity* are verifiable.
> If you mail client does not support S/MIME verification, it will display a
> file (smime.p7s), which includes the X.509 certificate and the signature
> body.  Read more at Certified E-Mail with Comodo and Thunderbird<http://abiusx.com/certified-e-mail-with-comodo-and-thunderbird/> in
> AbiusX.com
>
> On Mordad 6, 1392, at 5:56 PM, Sven Rautenberg <sven at rtbg.de> wrote:
>
> Which is probably a bad thing because the PHP time function does not
> expect to be called with any parameters, and code that uses
> \phpsec\time() will break if that function is not available.
>
> Regards,
> Sven
>
> Am 28.07.2013 15:20, schrieb Abbas Naderi:
>
> The name resolution under namespaces is, that PHP will search your name in
> current namespace and all its ascendants, respectively. So if you miss
> phpsec\time(), it will go for php's time().
> -A
> ______________________________________________________________
> Notice: This message is digitally signed, its source and integrity are
> verifiable.
> If you mail client does not support S/MIME verification, it will display a
> file (smime.p7s), which includes the X.509 certificate and the signature
> body.  Read more at Certified E-Mail with Comodo and Thunderbird in
> AbiusX.com
>
> On Mordad 6, 1392, at 2:51 PM, Sven Rautenberg <sven at rtbg.de> wrote:
>
> Yes, they do. Currently all your classes are in the same namespace, and
> will interfere with each other if defined.
>
> But this will only happen if the code has been included. Or is going to
> be autoloaded... (see issue #29 why this cannot currently be used).
>
> But even if autoloading would be implemented, you still cannot autoload
> simple functions, only classes.
>
> Regards,
> Sven
>
> Am 28.07.2013 12:10, schrieb rahul chaudhary:
>
> Hello All,
>
> I have this weird doubt...basic doubt.
>
> So two files that share a namespace, do they also share functions defined
> under that namespace ?
>
> e.g.:
> time.php defines function time() in namespace phpsec
>
> now in another file say testTime.php which is in same namespace, phpsec,
> can't I directly use this time function using \phpsec\time(). Do, I have to
> first use require_once("time.php") to call this function \phpsec\time()
>
>
>
> _______________________________________________
> OWASP_PHP_Security_Project mailing list
> OWASP_PHP_Security_Project at lists.owasp.org
> https://lists.owasp.org/mailman/listinfo/owasp_php_security_project
>
>
> _______________________________________________
> OWASP_PHP_Security_Project mailing list
> OWASP_PHP_Security_Project at lists.owasp.org
> https://lists.owasp.org/mailman/listinfo/owasp_php_security_project
>
>
>
>
>
>
> _______________________________________________
> OWASP_PHP_Security_Project mailing list
> OWASP_PHP_Security_Project at lists.owasp.org
> https://lists.owasp.org/mailman/listinfo/owasp_php_security_project
>
>


-- 
Regards,
Rahul Chaudhary
Ph - 412-519-9634
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.owasp.org/pipermail/owasp_php_security_project/attachments/20130728/75f6c2e2/attachment.html>


More information about the OWASP_PHP_Security_Project mailing list