本文整理汇总了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>