As pritaeas already explained trigger cannot consist of PHP code. There are only SQL and PSM (Persistent Storage Modul, yes, that's a standardized procedural programming language, not only like Oracle's pl/sql but partly derived from it) allowed within a trigger. You may consult SQL standard 2003.
Java, C, C++ or even PHP are not allowed until today. In the not-that-far future there could be triggers written in Java because Java has been designated to be the new procedural programming language for SQL. This important arrangement was made in the SQL standardization of 2003.
However, one can create a trigger fom within PHP5 using multi_query(string) as for instance:
/* Trigger example for MS SQL Server, Oracle, Sybase
Below trigger sample is based on standard 2003 PSM. Proprietary database systems, for instance MySQL, may have their own token and syntax or may plain omit some standarized PSM features.
$sql="CREATE TRIGGER myTrigger AFTER INSERT, UPDATE, DELETE ON myTable
REFERENCING OLD AS oRow NEW AS nRow
FOR EACH ROW
IF INSERTING THEN
-- Do something dealing with inserted data
ELSEIF UPDATING THEN
-- Do something dealing with updated data
ELSEIF DELETING THEN
-- Do something dealing with deleted data