tailieunhanh - Giải pháp thiết kế web động với PHP - p 21
USING PHP TO MANAGE FILES PHP Solution 7-5. If the hosting company refuses, you should consider moving to one with a better understanding of PHP. Configuration settings that affect local file access If the Local Value column for open_basedir or safe_mode_include_dir displays no value, you can ignore this section. However, if it does have a value, the meaning depends on whether the value ends with a trailing slash, like this: /home/includes/ In this example, you can open or include files only from the includes directory or any of its subdirectories. If the value doesn t have a trailing slash, the value after the. | USING PHP TO MANAGE FILES PHP Solution 7-5. If the hosting company refuses you should consider moving to one with a better understanding of PHP. Configuration settings that affect local file access If the Local Value column for open_basedir or safe_mode_include_dir displays no value you can ignore this section. However if it does have a value the meaning depends on whether the value ends with a trailing slash like this home includes In this example you can open or include files only from the includes directory or any of its subdirectories. If the value doesn t have a trailing slash the value after the last slash acts as a prefix. For example home inc gives you access to home inc home includes home incredible and so on-assuming of course that they exist or you have the right to create them. PHP Solution 7-1 shows what happens when you try to access a file outside the limits imposed by open_basedir. Creating a file storage folder for local testing Storing data inside your site root is highly insecure particularly if you need to set global access permissions on the folder. If you have access to a private folder outside the site root create your data store as a subfolder and give it the necessary permissions. For the purposes of this chapter I suggest that Windows users create a folder called private on their C drive. Mac users should create a private folder inside their home folder and then set Read Write permissions in the folder s Info panel as described in the previous chapter. Reading and writing files The restrictions described in the previous section reduce the attraction of reading and writing files with PHP. Using a database is more convenient and offers greater security. However that assumes you have access to a database and the necessary knowledge to administer it. So for small-scale data storage and retrieval working directly with text files is worth considering. Reading files in a single operation The simplest way to read the contents of a text file is to
đang nạp các trang xem trước