How Can I Make a Ghost Mode in PHP?

When developing your Website, you may find it useful to operate in a ghost mode while testing. A ghost mode is where public users do not have access to a Web page. If, however, your user has protected or private privileges, then that user can be shown data. The ghost mode is initiated within the opening lines of the PHP script. For example, you can add it to a "Class" tag, and this will place any of that tag within the ghost mode.

Instructions

    • 1

      Open your PHP script in Notepad.

    • 2

      Add the following class to the beginning:
      <?php
      /**
      * Define MyClass
      */
      class MyClass
      {
      protected $protected = 'Protected';
      private $private = 'Private';

      function printHello()
      {
      echo $this->protected;
      echo $this->private;
      }
      }

      In this instance, whenever you tag something with the "protected" or "private" tag, it will display only to those privileged users. The public users will not see the script. This page will now have a ghost mode.

    • 3

      Save your page.

Related Searches:

References

Comments

Related Ads

Featured