The code below is a method which is part of a class call rating. The bit of code below is just the first part of the OutputRating class I don't understand some of the functions it uses in it. such as addslashes and strlen. I have heard that the magic quotes functions is not necessary any more after php 5. But I think the rest of the code will need an explanation I will greatly appreciate your help. public static function OutputRating($varItem) { // Verify $varItem was provided if ($varItem != null && strlen(trim($varItem)) != 0) { // Check if Magic QUotes is ON if (!get_magic_quotes_gpc()) { $varItem = addslashes($varItem); } PHP:
strlen : returns the length of a string. addslashes: puts slashes infront of strange characters such as single qoutes. this makes strings safer to insert in mysql. trim: just takes away the spaces if they are at the start or end of the string. by the way, you can always go to php.net/THE_NAME_OF_THE_FUNCTION_GOES_HERE ex: php.net/strlen to check the details of any php function
strlen(trim($varItem)) != 0 i believe they are using 0 at this point because they are checking the length. But they could have used null as well.