PHP‎ > ‎

Common PHP Functions




str_replace(replacewhat, withwhat, infield)

strlen(field)


STRPOS:

strpos(inwhat, findwhat)   

NOTE:  this returns a 0 if it is the first character, not a 1.

You typically have to use a complex formula to check for null values:

if (strpos($row['Departments'],"Photo") !== false and strpos($row['Departments'],"Photo")>=0) 
{
    echo " checked ";
}

The reason you have to be careful is because doing a strpos(inwhat,findwhat)>=0 doesn't work, because if it doesn't find the value, it returns a 0, but if that value is in position 1 of the string, it also returns a zero.

Another way of doing it:

if (stripos($mynote, "sq")>0 or stripos($mynote,"sq")===0 )




TO make a folder:

$myfolder=$_SERVER['DOCUMENT_ROOT']."/uploads/James/";
if (!file_exists($myfolder)) {
    mkdir($myfolder, 0777, true);
}


Referencing file locations:
include $_SERVER['DOCUMENT_ROOT']."/uploads/orderid.php";



ERROR MESSAGES:

ini_set('display_errors', 0);



Comments