Hello.
Help me find an error in the code.
There are two text fields. When you enter a certain word in the first field and press enter, the source word should be replaced with a new one in the second text field.
On this code
<? $b = ''; if(isset($_POST['a'])){ $b = $_POST['a']; } ?> <? $s = $b $s = str_replace("ΠΏΡΠΈΠ²Π΅Ρ", "ΠΏΠΎΠΊΠ°"); $b = $s ?> <html> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <body> <br> Π ΠΏΠ΅ΡΠ²ΠΎΠ΅ ΡΠ΅ΠΊΡΡΠΎΠ²ΠΎΠ΅ ΠΏΠΎΠ»Π΅ Π²Π²Π΅Π΄ΠΈΡΠ΅ Π·Π°ΠΏΡΠΎΡ. ΠΠ°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΡ "ΠΎΡΠΏΡΠ°Π²ΠΈΡΡ". <br><br> <form method="post"> <input type='text' size="100" name='a'><br> <input type='text' size="100" name='b' value='<?=$b?>'> <input type='submit' value="ΠΡΠΏΡΠ°Π²ΠΈΡΡ"> </form> </body> </html> an error is displayed
"Parse error: syntax error, unexpected '$s' (T_VARIABLE) in ...test.php on line 11. 11 line is the code "$ s = str_replace (" hello "," bye "));"
Tried another code to use:
replaced this code
$s = str_replace("ΠΏΡΠΈΠ²Π΅Ρ", "ΠΏΠΎΠΊΠ°"); on
if (strpos($s, 'ΠΏΡΠΈΠ²Π΅Ρ') !== false) { $s = str_replace("ΠΏΡΠΈΠ²Π΅Ρ", "ΠΏΠΎΠΊΠ°", $s); } Displays the error "Parse error: syntax error, unexpected 'if' (T_IF) in ... test.php on line 11"
11 line is "if (strpos ($ s, 'hello')! == false) {"
Where did I make a mistake?