0

I'm debugging someone else old code, I think it has been made under php5 and I'm debugging after migrating to php8. The question I have is just about a syntax I haven't seen before, I don't know how to google and I can't test. I found this:

$aSelectedAssignmentFields=$advanced_options[assignment_fields];

And I don't know what it means. The value inside of the square brackets doesn't have a dollar sign or quotes. There is a class with that name but because of other issues I can't run it and check if that's right or wrong. It would be weird that is wrong, it would not that is outdated and in case it's right I would like to know what does it mean.

Thanks

2
  • 1
    Maybe this help you: stackoverflow.com/questions/14891464/… Commented May 2, 2022 at 17:37
  • 1
    var_dump($advanced_options) and check if it has a key assignment_fields. I guess they just forgot the quotes Commented May 2, 2022 at 17:37

1 Answer 1

3

It's impossible to do more than guess without more context; and may be impossible to be certain without a time machine to go back and ask the original developer (if you asked them now, I doubt they'd remember). I can think of two possibilities:

  1. It was intended to be a constant, and the definition has got lost somewhere. Most people right constants in upper-case, but there's never been anything in PHP itself to enforce that.
  2. It was intended to be a string, as in $aSelectedAssignmentFields=$advanced_options['assignment_fields']; Prior to PHP 8, there was an odd "feature" where an unquoted name which didn't match a constant would implicitly act like a quoted string. In PHP 5, it would have given a Notice; in PHP 7, a Warning; and in PHP 8, the functionality was removed and you get an error.
Sign up to request clarification or add additional context in comments.

2 Comments

Sure. I know what you mean. But you answered me already. It is a syntax error under php8. Most probably your second possibility, because I have found that syntax everywhere.
If you turn on error_reporting on your pre-8 app installs you'll likely see a boatload of warning/notice messages. This has never been acceptable, but as of PHP8 it is not longer ignorable. 3v4l.org/67KOM

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.