<p>The code below gives me this mysterious error, and i cannot fathom it. I am new to regular expressions and so am consequently stumped. The regular expression should be validating any international phone number.</p>

<p>Any help would be much appreciated.</p>

<pre><code>function validate_phone($phone)
{
    $phoneregexp ="^(\+[1-9][0-9]*(\([0-9]*\)|-[0-9]*-))?[0]?[1-9][0-9\- ]*$";

    $phonevalid = 0;

    if (ereg($phoneregexp, $phone))
    {
        $phonevalid = 1;
    }else{
        $phonevalid = 0;
    }
}
</code></pre>

If this is PHP, then the regex must be enclosed in quotes.
Furthermore, what's
```
preg
```
? Did you mean
```
preg_match
```
?
Another thing. PHP knows boolean values. The canonical solution would rather look like this:
```
```
return preg_match($regex, $phone) !== 0;
```
```
EDIT: Or, using
```
ereg
```
:
```
```
return ereg($regex, $phone) !== FALSE;
```
```
(Here, the explicit test against
```
FALSE
```
isn't strictly necessary but since
```
ereg
```
returns a number upon success I feel safer coercing the value into a
```
bool
```
).