At the initial stage of learning the programming language (PL) PHP, it is necessary to master the work with operators for outputting elements of text and HTML code, which will allow displaying an image on the user's screen during the execution of the script on the page. To display graphic files, the functions implemented in this PL can be used.
Instructions
Step 1
Open your PHP file for editing in any text editor by right-clicking on it and choosing "Open With". Select the utility that you use to modify the content of documents.
Step 2
The echo statement is used to produce the output of HTML elements. It is capable of displaying text, images and other elements used within the code. To display the graphic file on the user's screen, enter the following command in the desired section of the code:
echo ;
Step 3
In this code, instead of the line "path_to_image_file" specify the image file relative to the edited document. So, if you have uploaded an image named 1.
Step 4
In this example, quotes within the operator are preceded by the escape characters "". This indicates to the PHP interpreter that these brackets are used in other code and are not a signal to end the execution of the function, and therefore they must be escaped. The use of these symbols can be changed as follows:
echo ;
In this case, the back brackets have been replaced with the string concatenation operator.
Step 5
Without using the echo statement, you can use the following way:
<? php
// script code
…..
?>
<?
// continue execution of the program script
….
?>
Step 6
Using this approach, you interrupt the execution of the program script to output the image file using HTML. This output method is the simplest and no less efficient than when working with echo.
Step 7
Save the changes to the file via the "File" - "Save" menu and start your local server to debug the resulting script. You can also upload the edited file to your hosting and test its work on the site. Image output via PHP and HTML is now complete.