-2

I am currently checking the deprecated functions of a software developed in older PHP. It was developed in 2006. And I've seen a lot of variables in this format $_SESSION[name] or $_GET[name].

The issue here is that it does not give error on the deployed site. But in my local it gives Notice: Use of undefined constant name - assumed 'name'.

I know that I can solve this by adding single or double quotes on each variable but there are a lot to edit. And I have no access to the server configurations.

Any idea why this does not work on my local. I use PHP 5.6.

EDIT:: I just want to know the reason behind.

Thanks.

makoto
  • 177
  • 1
  • 4
  • 16

1 Answers1

0

In this kind of odd Scenario, you have a hint from the E-Notice: Notice: Use of undefined constant name - assumed 'name'. Since you don't have access to the server, (and until you do) You may simply create a temporal File say: _DEFINES.php and include it in your Scripts. Inside that File, you may just define those variables as Strings like so:

<?php 
    defined('name')           or define('name',           'name');
    defined('another_string') or define('another_string', 'another_value');
    defined('yet_another')    or define('yet_another',    'yet_another');

That way, you may have temporarily beat the nightmare...

NOTE: This is not much of a Solution... it is just a temporal work-around till you can fix the issue from the server-side....

Poiz
  • 7,611
  • 2
  • 15
  • 17
  • Thanks I can do that but what I need to know is the reason why it works.. I am using the copy of the live software. But it 'renders' differently. – makoto Sep 27 '16 at 06:41
  • 1
    @makoto The reason it works is already in the `E-Notice`. It is because it expects `name` to be a `String` but found something that appeared to be a `Constant`. Then since it cannot find that constant anywhere, PHP Engine automatically tries to help out by assuming/converting that `FALSE CONSTANT` to a `LITERAL STRING EQUIVALENT` and then tries to warn/inform you to `NOTICE` what it has done: **converted what seemed to be an undeclared Constant to a simple String.** That's it... – Poiz Sep 27 '16 at 07:03