Good day. There were problems during practice during the self-study of the book by Robin Nixon - Create dynamic websites using PHP, MySQL, JavaScript, CSS and HTML5. 3rd ed - 2015.

On page 173 (Exploring PHP> Creating a File), enter the code to create the file and check the result in the browser.

I enter the following code into the sublime text:

<?php $fh = fopen("testfile.txt", 'w') or die("Создать файл не удалось"); $text = <<<_END Строка 1 Строка 2 Строка 3 _END; fwrite($fh, $text) or die("Сбой записи файла"); fclose($fh); echo "Файл 'testfile.txt' записан успешно"; 

Then I save the file as testfile.txt and testfile.php, open it in the browser, but it doesn’t do anything.

The same is true when entering other examples (print functions, etc. - some biliberd is displayed in the browser window). What and how to enter - the textbook is not written. What am I doing wrong?

Thank.

    1 answer 1

    You can run php as a script from the console.

     $ php my_script.php 

    or set up a webserver and place your scripts there.

    • And where is it necessary to enter? Not very clear. - Dmitry Esin
    • on the Windows command line or console on Linux or Mac. - pavelip