本文整理匯總了PHP中Review::getError方法的典型用法代碼示例。如果您正苦於以下問題:PHP Review::getError方法的具體用法?PHP Review::getError怎麽用?PHP Review::getError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Review
的用法示例。
在下文中一共展示了Review::getError方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
?>
<h2>It should create a valid Review object when all input is provided</h2>
<?php
$validTest = array("firstName" => "Kay", "lastName" => "Robbins", "submissionID" => "R3023", "score" => "5", "review" => "This was a great presentation");
$s1 = new Review($validTest);
echo "The object is: {$s1}<br>";
$test1 = is_object($s1) ? '' : 'Failed:It should create a valid object when valid input is provided<br>';
echo $test1;
$test2 = empty($s1->getErrors()) ? '' : 'Failed:It not have errors when valid input is provided<br>';
echo $test2;
?>
<h2>It should extract the parameters that went in</h2>
<?php
$props = $s1->getParameters();
print_r($props);
?>
<h2>It should have an error when the first name contains invalid characters</h2>
<?php
$invalidTest = array("firstName" => "krobbins\$");
$s1 = new Review($invalidTest);
$test2 = empty($s1->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>';
echo $test2;
echo "The error for firstName is: " . $s1->getError('firstName') . "<br>";
echo "The object is: {$s1}<br>";
?>
</body>
</html>
示例2: array
?>
<h2>It should create a valid Review object when all input is provided</h2>
<?php
$validTest = array("reviewerName" => "Kay", "submissionId" => "R3023", "score" => "5", "review" => "This was a great presentation");
$s1 = new Review($validTest);
echo "The object is: {$s1}<br>";
$test1 = is_object($s1) ? '' : 'Failed:It should create a valid object when valid input is provided<br>';
echo $test1;
$test2 = empty($s1->getErrors()) ? '' : 'Failed:It not have errors when valid input is provided<br>';
echo $test2;
?>
<h2>It should extract the parameters that went in</h2>
<?php
$props = $s1->getParameters();
print_r($props);
?>
<h2>It should have an error when the first name contains invalid characters</h2>
<?php
$invalidTest = array("reviewerName" => "krobbins\$");
$s1 = new Review($invalidTest);
$test2 = empty($s1->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>';
echo $test2;
echo "The error for reviewerName is: " . $s1->getError('reviewerName') . "<br>";
echo "The object is: {$s1}<br>";
?>
</body>
</html>