site located on server or localhost, How can i find by using absolute path in php?

Votes : 3.6
238
My site has been developed on local machine, and do not error reporting on server. But report error, if site located on localhost. So i want to identify, where is the site located on server or localhost by using absolute path.

Your Answer

1 Answer

answered
If you want to check your site located on localhost. try this, function isESLocalhost($absPath = null) { /* * Check given absolute directory path from localhost. * @param (string|optional) $absPath - absolute directory path. * * @return (boolean) true/false. * * source : http://codrate.com/ */ $absPath = strtolower(trim(is_null($absPath) ? __FILE__ : $absPath)); return strpos($absPath, ':' . DIRECTORY_SEPARATOR) ? true : false; } /* eg: Check your web page's current absolute path */ var_dump(isESLocalhost()); // true /* eg: Check given absolute path */ var_dump(isESLocalhost('C:\wamp\www\code_projects\sample.php')); // true var_dump(isESLocalhost('home/codrate/public_html/code_projects/sample.php')); // false Or if you want to check your site located on server. try this, function isESServer($absPath = null) { /* * Check given absolute directory path from server. * @param (string|optional) $absPath - absolute directory path. * * @return (boolean) true/false. * * source : http://codrate.com/ */ $absPath = strtolower(trim(is_null($absPath) ? __FILE__ : $absPath)); return !strpos($absPath, ':' . DIRECTORY_SEPARATOR) && strpos($absPath, 'public_html') ? true : false; } /* eg: Check your web page's current absolute path */ var_dump(isESServer()); // true /* eg: Check given absolute path */ var_dump(isESServer('home/codrate/public_html/code_projects/sample.php')); // true var_dump(isESServer('C:\wamp\www\code_projects\sample.php')); // false

What is the codrate ?

codrate.com is a standard, fast cross browsing and highly versatile site. It is useful for many large number of Program Development Industries. So you can get support form Codrators , who are the codrate's joiners around world to help your program developments, You can answer other codrator's questions. Communicate with them. Share your knowledge with them. Do you have an interest in programming, So publish your articles about programming. It will help to maintain your professional co-profile. Actually codrate.com is not such as a regular web site. It will be gave new experience, best narrow cross-browser view, reduce processing time to receive browsing request, it's mean do not wasting your time to browsing codrate's web pages because it has been upgrade always modern coding ways. So, what do you waiting for ?. Try your own.

Copyright 2015 Pride - Company. Design by Esila