Search the Community
Showing results for tags '$_server[document_root]'.
-
Hallo phpfreaks, I`m new to this specific forum so I would like to contribute to some topics in the future. My question here is about absolute php paths. Right now I`m busy with making my own cms and I want to make it as flexible as possible. I`m not a fan of frameworks or library's so I`m making everything by myself (for this project). I already found a specific script that does exactly what I want to accomplish but I`m not so happy with that it uses $_SERVER['DOCUMENT_ROOT'] and this is the script that I found: substr( str_replace( '\\', '/', realpath(dirname(__FILE__))), strlen( str_replace( '\\', '/', realpath($_SERVER['DOCUMENT_ROOT'])))); At this moment I`m using Windows so this is the output that I get with it: /Projects/cms/5113/htdocs2 I was hoping that someone would know a alternative to the $_SERVER part. If it`s unclear what I`m trying to accomplish I`ll just write the whole story for you.
-
So, I'm starting the book "PHP and MySQL Web Development 4th Edition" and have a question about some code from chapter 2. In the sample script you declare a variable $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; This is then used later when opening/creating a file for writing: @ $fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", 'ab'); Unfortunately, it gives me an error saying the directory doesn't exist. Now if I eliminate the /.. part of the path it works fine. I seem to be having a reading comprehension problem as the text says ".." is used to mean "the parent directory of the document root directory" and I'm not entire sure what this means. Right now my orders folder is in the same folder as my script that executes this command: /Applications/XAMPP/xamppfiles/htdocs/processorder.php
- 2 replies
-
- fopen()
- $_server[document_root]
-
(and 2 more)
Tagged with: