Page 366 - Beginning PHP 5.3
P. 366

Part III: Using PHP in Practice
                  Testing the Editor

                   To try out your text editor, first create a folder somewhere on your Web server ’ s hard drive to store the
                 text files. Give the Web server user permission to create files in this folder. To do this on Linux and Mac
                 OS X, open a terminal window, then change to the parent folder and use the   chmod  command on the text
                 file folder. For example, if your text file folder was   /home/matt/sandbox , you could type:

                    $ cd /home/matt

                    $ chmod 777 sandbox
                   If you ’ re running a Windows Web server, see the  “ Changing Permissions ”  section earlier in the chapter
                 for details on how to change permissions. However, it ’ s quite likely that you won ’ t need to change
                 permissions for the script to work on Windows.

                  Once you ’ ve created your text files folder and given it appropriate permissions, you need to tell the
                 script about the new folder. To do this, set the   PATH_TO_FILES  constant at the top of the script:

                    define( “PATH_TO_FILES”, “/home/matt/sandbox” );
                  Now you ’ re all set. Open the text editor script ’ s URL in your Web browser and you should see a page
                 like Figure 11 - 4 (though it won ’ t list any files at this stage). Enter a new filename (minus the  “ .txt ”
                 extension) in the text field, and click Create File. You ’ ll see a form like the one shown in Figure 11 - 5
                 appear; enter your text and click Save File to save the changes to your new file. You can then reedit the
                 file by clicking its name in the list.


































                        Figure 11-4


              328





                                                                                                      9/21/09   9:10:21 AM
          c11.indd   328
          c11.indd   328                                                                              9/21/09   9:10:21 AM
   361   362   363   364   365   366   367   368   369   370   371