-2

How do I get my PHP to display on the browser? Currently, nothing is showing and I am not sure what is wrong?

<body>
testing

<?php
    echo "Hie there";
    print "Hello there";

?>

</body>

I expect it to display the echo but currently, nothing shows when I run it. Can you show me what is wrong with the code?

player0
  • 124,011
  • 12
  • 67
  • 124

3 Answers3

0

Files like .php must have a web-server to run them. Double clicking the html file won't do it. Try installing wamp or xampp or maybe host the file on a server somewhere and open the page again.

Visakh Vijayan
  • 648
  • 7
  • 16
-1

Php (php hypertext processor) unlike html, you will need a web server to run your scripts you can try xampp, and also you 'll have to save your php file as anything.php try and check W3schools php tutorial

-1

Ok so if you are runngin on a VPS login as root

and then Create a file named install with touch install and then run apt-get install nano and then you run this nano install and put this code here in it and press ctrl + x and y + enter

#!/bin/bash
clear
echo "This script will install all esseintials for php 7.3 for you"
sleep 3

apt update
apt upgrade -y
apt install ca-certificates apt-transport-https lsb-release curl nano unzip -y
wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add -
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
apt update
apt install apache2 -y
apt install php7.3 php7.3-cli php7.3-curl php7.3-gd php7.3-intl php7.3-json php7.3-mbstring php7.3-mysql php7.3-opcache php7.3-readline php7.3-xml php7.3-xsl php7.3-zip php7.3-bz2 libapache2-mod-php7.3 -y
apt install mariadb-server mariadb-client -y
clear
echo "Ok your done all has been setup."
echo "bye."

do not forget to make this file executable with chmod +x install

F.Ghost
  • 23
  • 7