Msencenb
Msencenb

Reputation: 5104

Having an @ inside of a string - PHP

So I know that you use a backslash to escape most things in php however the @ symbol is an operator that suppresses error messages.

I'm trying to put an email string like this inside of an array "[email protected]", however php is throwing an error.

How do you escape the @ sign?

EDIT: Here is the code example that was throwing the error:

$arr = array(3=> "[email protected]",4=> "[email protected]");

However replacing the double quotes with single quotes fixes the error as answered below.... why is that true?

Upvotes: 0

Views: 114

Answers (2)

Famver Tags
Famver Tags

Reputation: 1998

"[email protected]" should be '[email protected]', and it won't cause an error

Upvotes: 2

Rafe Kettler
Rafe Kettler

Reputation: 76955

If you've defined the string correctly, it won't cause an error. It doesn't need to be escaped.

Proof: http://www.ideone.com/Gd5am

Upvotes: 4

Related Questions