Vilx-
Vilx-

Reputation: 107062

nl2br in PHP suddenly doesn't work anymore

I noticed that one of my scripts wasn't working anymore, and started investigating. Eventually it boiled down to nl2br() not working anymore. Check out what results I get from a test script:

nl2br("asd",true): NULL
nl2br("asd",false): NULL
nl2br("asd"): string(3) "asd"

If the second parameter is specified, it returns NULL. WTF? The PHP installation on that box hasn't been touched in ages, it's an aging 5.2.6 on Apache2. Why has it stopped working all of a sudden?

Upvotes: 1

Views: 1409

Answers (2)

Ciprian L.
Ciprian L.

Reputation: 597

The second parameter has been added in 5.3.

My best guess: PHP interprets your comma as the comma operator, not as a delimiter for params, so it evaluates the expression to true or false instead of the string and that gets sent to the nl2br function.

Upvotes: 1

Related Questions