aximbigfan Posted August 28, 2008 Share Posted August 28, 2008 I need some way of figuring out if I'm in a Linux or Windows environment. I looked at predefined stuff, but they don't give me a solid answer. This is needed because I need to know whether to use "/"s or "\"s in paths. Thanks, Chris Link to comment https://forums.phpfreaks.com/topic/121647-determine-os-with-php/ Share on other sites More sharing options...
Ken2k7 Posted August 28, 2008 Share Posted August 28, 2008 I don't think PHP can do that. The most it can do is determine the OS the server is using. Well as far as my knowledge goes. Link to comment https://forums.phpfreaks.com/topic/121647-determine-os-with-php/#findComment-627552 Share on other sites More sharing options...
PFMaBiSmAd Posted August 28, 2008 Share Posted August 28, 2008 / works in file system paths in both operating systems. Do you have an example of something you are trying to do that does not work? Link to comment https://forums.phpfreaks.com/topic/121647-determine-os-with-php/#findComment-627555 Share on other sites More sharing options...
aximbigfan Posted August 28, 2008 Author Share Posted August 28, 2008 / works in file system paths in both operating systems. Do you have an example of something you are trying to do that does not work? Actually, I was trying to solve a problem before it started. So I could do a file_put_contents("test/test123/test.txt","This-is-a-test"); on Windows and it would work? Thanks, Chris Link to comment https://forums.phpfreaks.com/topic/121647-determine-os-with-php/#findComment-627561 Share on other sites More sharing options...
trq Posted August 28, 2008 Share Posted August 28, 2008 / works in file system paths in both operating systems. Do you have an example of something you are trying to do that does not work? Actually, I was trying to solve a problem before it started. So I could do a file_put_contents("test/test123/test.txt","This-is-a-test"); on Windows and it would work? Thanks, Chris Yes, php is smart enough to change / to \ on windows. Theres always the php_uname() function though, just to answer your question. Link to comment https://forums.phpfreaks.com/topic/121647-determine-os-with-php/#findComment-627565 Share on other sites More sharing options...
aximbigfan Posted August 28, 2008 Author Share Posted August 28, 2008 Huh... Well there goes about 15minutes implementing a system which I thought was smart. Thanks for your help everyone! Chris Link to comment https://forums.phpfreaks.com/topic/121647-determine-os-with-php/#findComment-627568 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.