Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
[PHP 7.3^] Kooser Directory.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Kooser6" data-source="post: 453420" data-attributes="member: 85580"><p>The slashes avoid naming collisions.</p><p></p><p><a href="https://stackoverflow.com/questions/3384204/what-are-namespaces/3384384#3384384" target="_blank">https://stackoverflow.com/questions/3384204/what-are-namespaces/3384384#3384384</a></p><p></p><p>It's also a security enhancement due to the fact of I did not use slashes and the code was vulnerable to code injection they could inject code to modify the function. Now if there was a slash the class will look to the global namespace to prevent that piece of code to vulnerability. Paragonie Initiative Enterprise also states this issue. Here is an example:</p><p></p><p></p><p>[CODE=php]<?php</p><p></p><p>namespace App;</p><p></p><p>class Foo</p><p>{</p><p> public function bar($data) {</p><p> echo count($data);</p><p> }</p><p>}</p><p></p><p>$foo = new Foo();</p><p>$foo->bar([1, 2, 3]);</p><p></p><p>// returns 3.</p><p> </p><p>}[/CODE]</p><p></p><p>Now here's what could happen:</p><p></p><p>[CODE=php]<?php</p><p></p><p>// injected code.</p><p>// <?php</p><p>//</p><p>// namespace App;</p><p>//</p><p>// function count($data) {</p><p>// return 24;</p><p>// }</p><p>//</p><p>// ?></p><p></p><p>namespace App;</p><p></p><p>class Foo</p><p>{</p><p> public function bar($data) {</p><p> echo count($data);</p><p> }</p><p>}</p><p></p><p>$foo = new Foo();</p><p>$foo->bar([1, 2, 3]);</p><p></p><p>// returns 24.</p><p> </p><p>[/CODE]</p><p></p><p>With the slash it still returns 3 because it's looking in the global namespace. Feel free to test this out for yourself.</p><p>[automerge]1569871515[/automerge]</p><p>Reason i made this wrapper is because not everyone knows how to properly secure their PHP web application.</p><p></p><p>Also you know how many classes are loaded in laravel and it still has optimal performance.</p></blockquote><p></p>
[QUOTE="Kooser6, post: 453420, member: 85580"] The slashes avoid naming collisions. [URL]https://stackoverflow.com/questions/3384204/what-are-namespaces/3384384#3384384[/URL] It's also a security enhancement due to the fact of I did not use slashes and the code was vulnerable to code injection they could inject code to modify the function. Now if there was a slash the class will look to the global namespace to prevent that piece of code to vulnerability. Paragonie Initiative Enterprise also states this issue. Here is an example: [CODE=php]<?php namespace App; class Foo { public function bar($data) { echo count($data); } } $foo = new Foo(); $foo->bar([1, 2, 3]); // returns 3. }[/CODE] Now here's what could happen: [CODE=php]<?php // injected code. // <?php // // namespace App; // // function count($data) { // return 24; // } // // ?> namespace App; class Foo { public function bar($data) { echo count($data); } } $foo = new Foo(); $foo->bar([1, 2, 3]); // returns 24. [/CODE] With the slash it still returns 3 because it's looking in the global namespace. Feel free to test this out for yourself. [automerge]1569871515[/automerge] Reason i made this wrapper is because not everyone knows how to properly secure their PHP web application. Also you know how many classes are loaded in laravel and it still has optimal performance. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
[PHP 7.3^] Kooser Directory.
Top