How should my PHP function handle invalid parameters?
<p>I'm creating some re-usable functions, and right now I have error handling setup like this:</p>

<pre><code>&lt;?php
...
public function insertAfter( $index, $objects )
{
    if ( ! is_int( $index ) ) {
        trigger_error( 'Cursor::insertAfter() expects parameter 1 to be integer, ' . gettype( $index ) . ' given', E_USER_WARNING );
    } else {
        // Do my regular code
    }

    return $this;
}
...
</code></pre>

<p>I tried setting it up to work just like PHP would handle an error. Is this an appropriate way to do things?</p>
