0

I have a web page running online with PHP 7.0 and MySQL 5.6 in a cloud provider dedicated. The web works fine (I did it in a text editor of a file manager provided by the cloud provider).

Now, I want to have the web into my Linux computer (I'm using Kubuntu). I have installed Apache2 2.4, PHP 7.0 and MySQL and same code of the online web (just copy and paste). But the problem is that some pieces of code show an error that is not shown in online web, for example:

if ($_SESSION['var'] == true) { .. }

I know that is not really correct, but in my online web this works when this session variable doesn't exists. However, in my computer, this code shows an error. I have to change it for:

if (isset($_SESSION['var']) && $_SESSION['var'] == true) { .. }

And the error is resolved. This is not the only case, we also obtain errors about array_pop(), etc. I know that I should fix that but it's a lot of code and I want to find a solution on my computer to skip this errors like the web is skipping right now.

I have tried on my computer to install PHP 7.0 and PHP 7.2 but the errors still appear...

Sorry for my bad English, just trying the best.

Regards.

Dan
  • 19
  • 4
  • 1
    Sounds like you just have different error reporting set up on the 2 machines. If `$_SESSION['var']` is not set that first conditional should always throw a notice. – user3783243 Aug 06 '18 at 00:48
  • And how can I say in/to my computer to don't attend "warnings" like errors? – Dan Aug 06 '18 at 00:49
  • 1
    @Dan fix those errors; production servers barely have error reporting enabled. – Martin Zeitler Aug 06 '18 at 00:50
  • @MartinZeitler They usually have it enabled, just logging instead of displaying. – user3783243 Aug 06 '18 at 00:51
  • @Dan You can see this thread to alter the reporting functionality https://stackoverflow.com/questions/2867057/how-do-i-turn-off-php-notices. – user3783243 Aug 06 '18 at 00:51
  • @user3783243 it is still not the optimum to mute errors & warnings; just because the other server does not complain, does not mean the code is correct. – Martin Zeitler Aug 06 '18 at 00:53
  • I also obtain errors like "syntax error, unexpected end of file" and I dont find where is de error. And in the online web this error doesn't not appear.. I'm so stressed right now :\ – Dan Aug 06 '18 at 00:53
  • @user3783243 still getting same errors using error_reporting(0); – Dan Aug 06 '18 at 00:54
  • The `unexpected end of file` error is different than what you have asked about. That is a fatal error, not a notice. The PHP is invalid. – user3783243 Aug 06 '18 at 00:54
  • @MartinZeitler I'm not advocating for ignoring errors, just provided link because that is what the OP initially asked. The `production servers barely have error reporting enabled` sounded like you were saying error reporting should disabled. – user3783243 Aug 06 '18 at 00:55
  • But I still don't understand how in the online web, this PHP file who shows me "unexpected end of file" can works fine out of my computer – Dan Aug 06 '18 at 00:59
  • I'm just solved the problems of the Notices with @user3783243 link. Thanks! But now my problem is about this Parse error. There are a lot of pages of my web with this problems and a lot of code... If on the cloud provider I can see the page fine, I should see it fine on my computer buy I don't know the way to do it.. – Dan Aug 06 '18 at 01:11
  • Not sure, maybe an `include` failed somewhere. You'll need to go through your files and see where the issue starts. It isn't good practice to just hide your errors, but that will mimic the behavior you described from the other server. – user3783243 Aug 06 '18 at 01:14
  • @Dan this might come from missing server modules, which the script may depend on; check with `phpinfo()` on the cloud, then install them locally with `sudo apt-get ...`. or just run `sudo apt list --installed | grep php`. – Martin Zeitler Aug 06 '18 at 01:27

0 Answers0