declare istring as int php code example Example: convert string to int php s = "123"; echo intval(s); // 123 s = "hello"; echo intval(s); //0