{"id":1024,"date":"2013-03-25T22:10:03","date_gmt":"2013-03-26T05:10:03","guid":{"rendered":"http:\/\/www.designersgate.com\/blogs\/?p=1024"},"modified":"2013-03-25T22:10:03","modified_gmt":"2013-03-26T05:10:03","slug":"sensitive_data_exposed","status":"publish","type":"post","link":"https:\/\/designersgate.com\/blog\/sensitive_data_exposed\/","title":{"rendered":"How to Avoid Having Sensitive Data Exposed"},"content":{"rendered":"<p>There are few reasons why you have to have sensitive information inside a class, but the one in the top of these reasons is because many hosting services does not allow you to have access to your root folder or even to your php.ini file.<\/p>\n<p>This is a big problem specially if you have a customer that&#8217;s not willing to invest much in a website. Shared Hostings are the cheapest options but not all of them allow you access, as I said before, to a root folder that&#8217;s not exposed to the public.<\/p>\n<p>When you creating a class there is a simple way where you can protect sensitive data with the variables. As I explained in <a title=\"Controlling How Your Variables Are Handled In a PHP Class\" href=\"http:\/\/www.designersgate.com\/blogs\/controling-how-your-variables-are-handled-in-a-php-class\/\" target=\"_blank\" rel=\"noopener noreferrer\">Controlling Your Variables In A PHP Class<\/a>, there are ways to create variables that are protected from being changed if it is not through a method, there are also a way to avoid exposed information when an object is created. For a basic tutorial about classes read <a title=\"How to Create a PHP Class\" href=\"http:\/\/www.designersgate.com\/blogs\/create-php-class\/\" target=\"_blank\" rel=\"noopener noreferrer\">PHP Basic: How To Create A PHP Class<\/a>.<\/p>\n<p>As most of you know, specially those who wants to harm your website, when you create an object and you hold this object in a variable, every variable is exposed, except those who properly set up, but regular protected variables are exposed as well as any other variable that&#8217;s not set as private.<\/p>\n<p>Constants are the worst option to have sensitive data on it. Constants are not exposed in the object but are accessible from the object, for example:<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure\/\" rel=\"attachment wp-att-1031\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1031\" alt=\"Creating a more secure class\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure.jpg\" width=\"551\" height=\"288\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure.jpg 551w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure-300x157.jpg 300w\" sizes=\"auto, (max-width: 551px) 100vw, 551px\" \/><\/a><\/p>\n<p>The above code will output:<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure2\/\" rel=\"attachment wp-att-1032\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1032\" alt=\"Create a more secure class 002\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure2.jpg\" width=\"504\" height=\"281\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure2.jpg 504w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure2-300x167.jpg 300w\" sizes=\"auto, (max-width: 504px) 100vw, 504px\" \/><\/a><\/p>\n<p>So, as you see this is not a good way to save your sensitive data. Then, What can you do to protect your data? There are many ways you can protect your data, but none of them can guaranteed you to be 99.9% secure, or even 80%. But if you have no other choice you have to deal with it, or at least until your contract with your hosting company finishes. When this does happens I would recommend to move to a hosting service that allow your access to root folders, as <a title=\"Blues Host hosting from $5.95 a month\" href=\"http:\/\/www.bluehost.com\/track\/raphievila\/CODE78\" target=\"_blank\" rel=\"noopener noreferrer\">Blue Host<\/a> does.<\/p>\n<p>For the moment this are some ideas you can use:<\/p>\n<h2>Secure Your Classes<\/h2>\n<p>Make a folder in your public root folder specific for your classes and secure it with an <code style=\"font-style: inherit;\">.htaccess<\/code> file, if your system is Apache based; Most\u00a0inexpensive web hosting are, due to those hosting are based in an opensource server as Apache (Linux\/Debian). For a good <code>.htaccess<\/code> and <code>.htpasswd<\/code>\u00a0generator visit <a title=\"Dynamic Drive .htaccess password generator\" href=\"http:\/\/tools.dynamicdrive.com\/password\/\" target=\"_blank\" rel=\"noopener noreferrer\">Dynamic Drive<\/a> website, I&#8217;ve been using it for years. This option just add a certain security shield, but because you don&#8217;t have access to the root folder you need to put this files together inside the folder you want to protect, unless your hosting service at least provide you with your root system URL, allowing you to target another folder other than the same folder your storing the\u00a0<code style=\"font-style: inherit;\">.htaccess<\/code> file. I will explain this in more details in another tutorial.<\/p>\n<h2>Use Protected Static Variable More Often<\/h2>\n<p>The variables you use in your class should be planned carefully, which variables are going to be exposed? (public variable), which ones are going to have limited access? (protected or private variable), and which ones should not be visible only by the app? (protected static variables).<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1035\" alt=\"More Secure PHP Class 003\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure3.jpg\" width=\"527\" height=\"418\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure3.jpg 527w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure3-300x238.jpg 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/a><\/p>\n<p>In the illustration above I set up two protected variables then see how they are exposed when you call the object and echo it:<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure4\/\" rel=\"attachment wp-att-1036\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1036\" alt=\"More Secure PHP Class 004\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure4.jpg\" width=\"502\" height=\"362\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure4.jpg 502w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure4-300x216.jpg 300w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/a><\/p>\n<p>It is obvious that this is not a very effective way to save sensitive information, so we need to get some other measures. This measures are simple but effective in most cases. Let&#8217;s modify a little bit our code:<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure5\/\" rel=\"attachment wp-att-1037\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1037\" alt=\"Setting up a static secured variable\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure5.jpg\" width=\"562\" height=\"230\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure5.jpg 562w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure5-300x123.jpg 300w\" sizes=\"auto, (max-width: 562px) 100vw, 562px\" \/><\/a>Now that we have our first protected static variable let see how it is exposed:<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure6\/\" rel=\"attachment wp-att-1038\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1038\" alt=\"The static protected variable is not exposed!\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure6.jpg\" width=\"483\" height=\"352\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure6.jpg 483w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure6-300x219.jpg 300w\" sizes=\"auto, (max-width: 483px) 100vw, 483px\" \/><\/a><\/p>\n<p>And as you can see this type of variable is not visible, and can only be used inside the class. But let&#8217;s try to echo this value to see what happens:<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure7.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1039\" alt=\"Trying to echo protected static values\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure7.jpg\" width=\"435\" height=\"158\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure7.jpg 435w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure7-300x109.jpg 300w\" sizes=\"auto, (max-width: 435px) 100vw, 435px\" \/><\/a><\/p>\n<p>We have added an echo to our code, but this is the result:<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure8\/\" rel=\"attachment wp-att-1040\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1040\" alt=\"An Internal Server Error is thrown by the browser\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure8.jpg\" width=\"612\" height=\"380\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure8.jpg 612w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure8-600x373.jpg 600w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure8-300x186.jpg 300w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/><\/a><\/p>\n<p>Obviously PHP will throw an error because protected methods cannot be used outside the class. But let&#8217;s set an ini_set() to display the errors, to see what type of error is PHP throwing:<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure9\/\" rel=\"attachment wp-att-1041\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1041\" alt=\"Exposing the errors\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure9.jpg\" width=\"589\" height=\"569\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure9.jpg 589w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure9-300x290.jpg 300w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><\/a><\/p>\n<p>I added ini_set(&#8216;display_errors&#8217;,&#8217;On&#8217;) to change this variable in the php.ini file, this way we can see the error as in displayed by PHP. Let&#8217;s see the error:<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure010\/\" rel=\"attachment wp-att-1042\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1042\" alt=\"The returned error\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure010.jpg\" width=\"1071\" height=\"411\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure010.jpg 1071w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure010-600x230.jpg 600w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure010-300x115.jpg 300w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure010-1024x393.jpg 1024w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure010-768x295.jpg 768w\" sizes=\"auto, (max-width: 1071px) 100vw, 1071px\" \/><\/a><\/p>\n<p>As you can see, we cannot used protected methods outside the class, because they are not exposed. They just hold data to be used by the class, you can use this data to set a value of a public variable if you like, this if you want to exposed this variable outside the box:<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure011\/\" rel=\"attachment wp-att-1043\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1043\" alt=\"Exposing static values using public variables\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure011.jpg\" width=\"628\" height=\"682\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure011.jpg 628w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure011-600x652.jpg 600w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure011-276x300.jpg 276w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/a><\/p>\n<p>Then I can use this public variable to echo the value of the static variable. Probably this will never happen but is just an example how to exposed this values if you need to. But before we need to remove lines 34 and 35 so the previous error is not shown. After doing that we can see the result.<\/p>\n<p><a style=\"font-style: normal; line-height: 24px; text-decoration: underline;\" href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure012\/\" rel=\"attachment wp-att-1044\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1044\" style=\"border-color: #bbbbbb; background-color: #eeeeee;\" alt=\"Exposing a static value with a public method\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure012.jpg\" width=\"605\" height=\"387\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure012.jpg 605w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure012-600x384.jpg 600w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure012-300x192.jpg 300w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/a><\/p>\n<p>With the result, let&#8217;s move along. Not only variables can be static. One thing you need to understand is that static objects inside your class cannot be manipulated by public functions. To accomplish this outside the function you need to create a public function that execute a static protected function. As I said, you probably will never want to do that, but it is the same principle to manipulate static data inside the class&#8230; so let&#8217;s get our hands dirty:<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure013\/\" rel=\"attachment wp-att-1045\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1045\" alt=\"Manipulating variables outside the class\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure013.jpg\" width=\"447\" height=\"197\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure013.jpg 447w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure013-300x132.jpg 300w\" sizes=\"auto, (max-width: 447px) 100vw, 447px\" \/><\/a><\/p>\n<p>In the code above I&#8217;m manipulating the value of the public variable $message to hold the same value of the constant PHPCONSTANT, when I run the code this value is exposed by the $message variable.<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure015\/\" rel=\"attachment wp-att-1046\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1046\" alt=\"The $message variable exposing constant value\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure015.jpg\" width=\"667\" height=\"427\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure015.jpg 667w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure015-600x384.jpg 600w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure015-300x192.jpg 300w\" sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><\/a><\/p>\n<p>Now, if we trying to do this with the static variable we going to have an error like before, because we are trying to use a protected object outside the class&#8230; not good!<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure016\/\" rel=\"attachment wp-att-1048\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1048\" alt=\"Trying to use protected method\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure016.jpg\" width=\"512\" height=\"166\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure016.jpg 512w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure016-300x97.jpg 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure017\/\" rel=\"attachment wp-att-1049\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1049\" alt=\"Throwing another error\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure017.jpg\" width=\"936\" height=\"392\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure017.jpg 936w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure017-600x251.jpg 600w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure017-300x126.jpg 300w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure017-768x322.jpg 768w\" sizes=\"auto, (max-width: 936px) 100vw, 936px\" \/><\/a><\/p>\n<h2>Manipulating Static Data<\/h2>\n<p>If you really need to use or manipulate an static outside the class, which makes no sense, then your will have to make a clever code able to manipulate these values, but because the values are set outside the class you should always protect your application from injection attempts, here I will only use htmlspecialchars() function, that might stop some Cross Scripting but you need something more clever than that, believe me.<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure018\/\" rel=\"attachment wp-att-1050\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1050\" alt=\"Setting up functions\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure018.jpg\" width=\"552\" height=\"496\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure018.jpg 552w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure018-300x270.jpg 300w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/a><\/p>\n<p>In this code I created 3 new functions, <strong>changeStatic()<\/strong> is the actual function that will update the value of the static variable, as you see I&#8217;m using the dynamic variable method that can be accomplished like:<\/p>\n<p><code>${$variable} = $value;<\/code><\/p>\n<p>The same method you use to create a PHP variable, starting with the dollar sign ($), then you will enclosed a variable which hold a value that it is the name of the variable to be set is curly brackets ({ }), I will be setting up the $password static variable. The dynamic variable will be set by the $name variable in the function and the $value variable obviously will hold the new value to be set.<\/p>\n<p>The <strong>setStatic()<\/strong> function then is the one that&#8217;s going to be executed outside the class, as you see I filtering the $name and the $value variables in this function. As I said, this is a lousy method to protect your variable but will clean any html tags that are sent through the function. For a more advanced method to process exposed I\/O data <a title=\"Symantec - SQL Injection Detection\" href=\"http:\/\/www.symantec.com\/connect\/articles\/detection-sql-injection-and-cross-site-scripting-attacks\" target=\"_blank\" rel=\"noopener noreferrer\">check this whitepaper from Symantec<\/a>.<\/p>\n<p>Then I created also another public function that will pass the new $password value set by these two function to the public $message variable, called <strong>showStatic()<\/strong>. With all this done, then we can use the public functions outside the class to set internal values.<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure019\/\" rel=\"attachment wp-att-1051\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1051\" alt=\"Calling method outside the class\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure019.jpg\" width=\"517\" height=\"159\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure019.jpg 517w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure019-300x92.jpg 300w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/a><\/p>\n<p>When executing the function, we are setting the $name variable with a string value of <span style=\"color: #339966;\"><em>password<\/em><\/span> and the $value variable with another string value of <span style=\"color: #ff0000;\"><em>2535<\/em><\/span>. Then we are going to execute the second public function <strong>showStatic()<\/strong> where we set the $name value with static variable name that we want to expose, in this case &#8216;password&#8217;. This is the result.<\/p>\n<p><a href=\"http:\/\/www.designersgate.com\/blogs\/sensitive_data_exposed\/phpclass-secure020\/\" rel=\"attachment wp-att-1052\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1052\" alt=\"Exposing new value\" src=\"http:\/\/www.designersgate.com\/blogs\/wp-content\/uploads\/2013\/03\/phpClass-secure020.jpg\" width=\"558\" height=\"400\" srcset=\"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure020.jpg 558w, https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/phpClass-secure020-300x215.jpg 300w\" sizes=\"auto, (max-width: 558px) 100vw, 558px\" \/><\/a><\/p>\n<p>As you can see, the phpClass Object is not exposing any of those values, the static methods and variables can only be executed inside the class if they are protected and can only be exposed if you allow it. This gives you more control of your variables and allow your to develop more secure pieces of reusable codes and objects with PHP.<\/p>\n<p><span style=\"color: #339966;\"><em>Resources:\u00a0In this tutorial I&#8217;m using WebMatrix the free web developing tool from Microsoft as my IDE and IE 10 for browser.<\/em><\/span><\/p>\n<p>Happy Coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are few reasons why you have to have sensitive information inside a class, but the one in the top of these reasons is because many hosting services does not allow you to have access to your root folder or even to your php.ini file. This is a big problem specially if you have a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1054,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13,7],"tags":[8,75,129,3,9,58,130,76,15,131,34,77,45,64,29,89,132,91,133,52,134,6,81,92,135,82],"class_list":["post-1024","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips","category-tutorials","tag-browsers","tag-coding","tag-constants","tag-design","tag-display","tag-error","tag-errors","tag-filter","tag-functions","tag-htmlspecialchars","tag-ie","tag-injection","tag-internet","tag-object","tag-php","tag-private","tag-protected","tag-public","tag-secure","tag-software","tag-static","tag-tutorial","tag-validation","tag-variables","tag-webmatrix","tag-xss"],"acf":[],"jetpack_featured_media_url":"https:\/\/designersgate.com\/blog\/wp-content\/uploads\/2013\/03\/DESIGNERS-GATE-PHP-SECURITY.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/posts\/1024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/comments?post=1024"}],"version-history":[{"count":0,"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/posts\/1024\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/media\/1054"}],"wp:attachment":[{"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/media?parent=1024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/categories?post=1024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/designersgate.com\/blog\/wp-json\/wp\/v2\/tags?post=1024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}