If you are running an Apache web server under OS X El Capitan and want to use PHP with Apache, you will need to take some additional steps after you've got Apache running on OS X/macOS. Once you've got Apache working on the system, you can create a .php file, e.g.
phptest.phpand have the page displayed by your browser if you visit the page, but PHP code within the page won't be executed. E.g., suppose the
phptest.phppage contains the following code:
<!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <title>PHP Test</title> </head> <body> <h2>A test page</h2> <?php phpinfo(); ?> </body> </html>
If I visit the page using a browser, the HyperText Markup Language
(HTML) code on the page will be displayed, e.g. the "A test page"
heading will be displayed, but the information that the
command would display regarding the PHP settings for a system on which
PHP is working won't be displayed. You could also try a simple PHP echo
<?php echo "This is the output from a PHP echo
command."; ?>, but the output from that command would not be
[ More Info ]