From the course: PHP: Creating Secure Websites

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Keeping code private

Keeping code private - PHP Tutorial

From the course: PHP: Creating Secure Websites

Start my 1-month free trial

Keeping code private

- [Instructor] Controlling output also means controlling visibility. And there are parts of our application we choose to show users like the HTML output, but even more parts that we want to keep hidden like our application logic, functions, and database passwords. Because of that, you should always organize your code into public and private areas. The public directory can be accessible to the web server. It would contain mostly your presentation code, page templates, content that you are going to show the user anyway. You still want to be smart about the code that you put in public pages though. Keep them minimal. For more complicated code, the public pages can call classes and functions, which are stored in private libraries. Those private libraries could be in a directory that's not accessible to the web server, but would still be accessible to your code because your code has access to the file system. Most PHP…

Contents