note 71630 added to ref.exec

From: Date: Fri, 08 Dec 2006 18:50:53 +0000
Subject: note 71630 added to ref.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-120440@lists.php.net to get a copy of this message
Just a simple note to help people get rid of some headaches. when using: <? $filepath = "the path of the file"; exec("program -command $filepath "); fopen($filepath,rw); ?> Make sure you use "\ " ( \ space) for the Linux\unix path and just " " space for fopen. These are both very basic things that you wouldn't normally think to cause a problem, but when you try to pass slashes to fopen it either breaks or even better works incorrectly =D. And vise versa for any programs that use "\ " for spaces in file paths/names. I ran into this problem when using <? exec(" cp $path "); ?> and <? fopen("$path"); ?>. To fix it I used str_replace(" ","\ ",$path); and str_replace("\ ", " ",$path); *Note this is alot of sudo code, and there are faster more effecient ways of doing the same operations, but I thought this might help those who were going crazy over filepaths =D. ---- Server IP: 216.194.113.175 Probable Submitter: 67.78.160.130 ---- Manual Page -- http://www.php.net/manual/en/ref.exec.php Edit -- https://master.php.net/note/edit/71630 Del: integrated -- https://master.php.net/note/delete/71630/integrated Del: useless -- https://master.php.net/note/delete/71630/useless Del: bad code -- https://master.php.net/note/delete/71630/bad+code Del: spam -- https://master.php.net/note/delete/71630/spam Del: non-english -- https://master.php.net/note/delete/71630/non-english Del: in docs -- https://master.php.net/note/delete/71630/in+docs Del: other reasons-- https://master.php.net/note/delete/71630 Reject -- https://master.php.net/note/reject/71630 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120440) next »