Unable to run PHP 7 in browser

General Tech Bugs & Fixes . 2 years ago

  0   2   0   0   0 tuteeHUB earn credit +10 pts

5 Star Rating 5 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Write Your Comments or Explanations to Help Others



Tuteehub forum answer Answers (2)


profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I have successfully installed PHP 7 using this link.

When I run following command in terminal

php -v

it successfully show that PHP 7 version detail.

But when I run a test.php file (made in web accessible folder and it has below content )

phpinfo();

in browser like localhost/test.php it still shows me my older version of PHP ie 5.5.9.

In browser every PHP script works fine but with PHP 5.5.9 not with PHP 7

And In terminal every PHP script works fine with PHP 7 but in browser, it works with PHP 5.5.9 not with PHP 7.

For example a file ano_class.php having anonymous class feature added in PHP 7 works as fine in terminal by following command

php ano_class.php

It successfully print expected results, but when I run the same file in browser like localhost/ano_class.php it gives me syntax error because anonymous class is not supported in PHP 5.5.9

I have done many research on internet but doesn't get the answer

Though I have referred many website, I referred here too.

How to get PHP 7 running in non CLI mode?

(I am using LAMP IN Kubuntu 14.04 )

0 views   0 shares
profilepic.png
manpreet 2 years ago

Depends on your webserver I am going to assume apache2 and will assume that you have

If you have php7 enabled in apache it should look something like

ls /etc/apache2/mods-enabled/ | grep php
php7.0.conf
php7.0.load

If you see php5 in there try

ls /etc/apache2/mods-availible/ | grep php

If php7.0 is an availible mod you should be able to

sudo a2dismod php5
sudo a2enmod php7.0
sudo service apache2 restart

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community