PHP script stops when a member function is called, no error thrown
What can cause php script to stop executing without outputting any error? It happens to m开发者_C百科e when I call an inherited function.
Example code:
class X extends FPDF {
function foo() {
return $this->GetClientWidth();
}
}
FPDF class as in here: (deleted link) wrong version
The object is initiated, anytime I call GetClientWidth() I get a blank page
Used to work before reinstalling my OS/dev environment. Running on XAMPP
UPDATE: Sorry for confusing you, I didn't check the link I gave, it indeed did not have the function discussed. It's there though on my local version.
error_reporting(E_ALL);
ini_set('display_errors',1);
or check error.log
require_once "FPDF.php";
error_reporting(E_ALL);
ini_set('display_errors',1);
class X extends FPDF {
function foo() {
return $this->GetClientWidth();
}
}
$x = new X;
$ClienWidth = $x->foo();
var_dump($ClienWidth);
return:
Fatal error: Call to undefined method X::GetClientWidth()
The reason is simple: "There is no GetClientWidth method in the fpdf – Prisoner"
Add the following code right at the beginning of your script and check if any error is displayed.
error_reporting(E_ALL);
ini_set('display_errors', true);
when it happens to me is because the method does not exist.
I've revised your object FPDF an it's not defined
精彩评论