Semantic Errors

Semantic errors are a bit harder to track down than syntax errors. The errors can be somewhat vague even though they give line numbers. Take a look at the following example:

<?php
socket_create($socket, ‘localhost’, ‘tcp’);
?>

This generates the error shown in Figure C.3. This error says that the second parameter is supposed to be a long but a string was given. But the second parameter is perfectly legitimate. It is the third parameter that is incorrect. It should read:

Figure C.3. A semantic error.


socket_create($socket, ‘localhost’, SOL_TCP);

See what I mean when I say that the errors are somewhat vague? These errors are still fairly easy to track down. Usually when you stare at the specified line of code for a moment, the fix dawns on you. If the fix doesn’t come to you then go to www.php.net and type in the function name in the search box. This will bring up the documentation for the particular function so you can determine where you went wrong.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset