PHP: <?php if (!isset($_POST['print'])) { ?> <form action=<?php echo $_SERVER['PHP_SELF']; ?> method=POST> <input type="text" name="name" /> <input type="text" name="surname" /> <input type="text" name="phone" /> <input type="text" name="job" /> <input type="submit" name="print" value="print" /> </form> <?php } else { unset($_POST['print']); foreach ($_POST as $k => $v) { $_POST[$k] = ereg_replace('<', '', $_POST[$k]); $_POST[$k] = ereg_replace('>', '', $_POST[$k]); $_POST[$k] = ereg_replace("\'", '', $_POST[$k]); $_POST[$k] = ereg_replace("\"", '', $_POST[$k]); $_POST[$k] = ereg_replace("\/", '', $_POST[$k]); $_POST[$k] = ereg_replace("\\", '', $_POST[$k]); } ?> <div><?php echo $_POST['name']; ?></div> <div><?php echo $_POST['surname']; ?></div> <div><?php echo $_POST['phone']; ?></div> <div><?php echo $_POST['job']; ?></div> <script language=javascript>window.print();</script> <?php } ?> выдает ошибку в 25 строке. помогите пожалуйста!
PHP: <? $_POST[$k] = ereg_replace('\\\\', '', $_POST[$k]); А почему не preg_replace, который быстрее И почему вообще не str_replace?
спасибо вам. даже забыл об этом. все на str_replace сделал и так $_POST[$k] = str_replace("\\", '', $_POST[$k]); пашет.
В рот мне ноги! Почему у Вас на каждую функцию по 1 заменительному знаку? Ведь массив можно использовать.
Код (Text): $search = array("<", ">", "'", "\"", "/", "\\"); foreach ($_POST as $k => $v) $_POST[$k] = str_replace($search, '', $_POST[$k]); так пойдет?
Нет =) PHP: <?php $replaces = Array ( '>' => "", "\'" => "", "\"" => "", "\/" => "", "\\" => "" ); $_POST[$k] = strtr($_POST[$k], $replaces); ?>