note 76363 added to security

From: Date: Thu, 12 Jul 2007 05:34:48 +0000
Subject: note 76363 added to security
Groups: php.notes 
Request: Send a blank email to php-notes+get-128398@lists.php.net to get a copy of this message
First, q much simpler solution to preventing people from viewing code inside of an includable file would be to give include file an extension that ends with php (e.g. myFile.inc.php). Secondly, and more importantly, why on earth would you want to put program-level code in an include file? By that I mean something life this: myFile.inc.php -------------------------------- ... if ($var = 'whatever') // connect to the database else // do something else. -------------------------------- An include file should not contain logic! Rather, it is an encapsulated unit of code that should not do anything on its own unless asked to. To implement this ideology, consider including function definitions only in your include files, then once you include them in the script, call such functions from within your program (i.e. the script that included the inc file). If you don't know the names of the functions ab initio, use call_user_func() or call_user_func_array() and pass it the name of the function that's dependent on context. If you MUST put program-level logic in your include files, consider simply putting it in the program! Why should you consider this? How about variable name clashes for a starter! You can think of more, I am shure! Hope that helped ---- Server IP: 69.147.83.197 Probable Submitter: 196.205.206.106 ---- Manual Page -- http://www.php.net/manual/en/security.php Edit -- https://master.php.net/note/edit/76363 Del: integrated -- https://master.php.net/note/delete/76363/integrated Del: useless -- https://master.php.net/note/delete/76363/useless Del: bad code -- https://master.php.net/note/delete/76363/bad+code Del: spam -- https://master.php.net/note/delete/76363/spam Del: non-english -- https://master.php.net/note/delete/76363/non-english Del: in docs -- https://master.php.net/note/delete/76363/in+docs Del: other reasons-- https://master.php.net/note/delete/76363 Reject -- https://master.php.net/note/reject/76363 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128398) next »