manalnor Posted September 2, 2010 Share Posted September 2, 2010 Hello friends, I've php script that create files for example you enter file name (ex : test.php) file content (ex: any text ) it will create test.php file with the same content you entered. but the problem it add back slah \ before " or ' how can i stop it and make it not add back slash before " and ' here is the code <?php function saveFile($filename,$filecontent){ if (strlen($filename)>0){ $file = @fopen($filename,"w"); if ($file != false){ fwrite($file,$filecontent); fclose($file); return 1; } return -2; } return -1; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain" id="domain"> File name: <input name="filename" type="text" value="<?php echo $domainbase; ?>" /> File content: <textarea name="filecontent" rows="15" cols="46"></textarea> <input type="submit" name="submitBtn" value="Save file" /> </form> <?php if (isset($_POST['submitBtn'])){ $filename = (isset($_POST['filename'])) ? $_POST['filename'] : '' ; $filecontent = (isset($_POST['filecontent'])) ? $_POST['filecontent'] : '' ; if (saveFile($filename,$filecontent) == 1){ echo "File was saved"; } else if (saveFile($filename,$filecontent) == -2){ echo "An error occured during saving file"; } else if (saveFile($filename,$filecontent) == -1){ echo "Wrong file name"; } } ?> thank you alot it will really helps me alot Link to comment https://forums.phpfreaks.com/topic/212320-stop-that-back-slash/ Share on other sites More sharing options...
trq Posted September 2, 2010 Share Posted September 2, 2010 stripslashes. Link to comment https://forums.phpfreaks.com/topic/212320-stop-that-back-slash/#findComment-1106265 Share on other sites More sharing options...
RussellReal Posted September 2, 2010 Share Posted September 2, 2010 why are you using savefile() 3 times just for if and elseif statements.. why not save file ONCE and then store that in a variable THEN do the checks Link to comment https://forums.phpfreaks.com/topic/212320-stop-that-back-slash/#findComment-1106267 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.