Richard Knop
Richard Knop

Reputation: 83755

nl2br second parameter doesn't work

This:

var_dump(nl2br("aaa\naaa", false));

Outputs:

NULL

I am using PHP Version 5.2.13. Doctype is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

Upvotes: 1

Views: 222

Answers (3)

Alex Pliutau
Alex Pliutau

Reputation: 21947

Only in PHP 5.3 there are second arg in nl2br.

Upvotes: 1

deceze
deceze

Reputation: 522635

The second false parameter was added in PHP 5.3. Older versions of the function probably fail if passed an extra parameter they don't expect. Local experiments confirm this, the code runs fine on PHP 5.3 and fails on 5.2.10.

Upvotes: 2

Phil
Phil

Reputation: 165069

Have a look at the changelog. The second parameter was added in PHP 5.3.0

Upvotes: 2

Related Questions