当前位置: 首页>>代码示例>>PHP>>正文


PHP UserData::getError方法代码示例

本文整理汇总了PHP中UserData::getError方法的典型用法代码示例。如果您正苦于以下问题:PHP UserData::getError方法的具体用法?PHP UserData::getError怎么用?PHP UserData::getError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserData的用法示例。


在下文中一共展示了UserData::getError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

<?php 
$invalidUser = array("userName" => "Thugnificent", "picture" => "../images/thugnificent.jpg", "firstName" => "Otis", "lastName" => "Jenkins", "address" => "123 Thug Lane", "neighborhood" => "Woodcrest", "dateOfBirth" => "1989-01", "gender" => "male", "comedy" => "checked", "email" => "thugnasty.gmail.com", "phone" => "(210) 555 - 5555", "url" => "https://otis_jenkins/facebook.com");
$userDataTest11 = new UserData($invalidUser);
$test2 = empty($userDataTest11->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>';
echo $test2;
echo "The error for email is: " . $userDataTest11->getError('email') . "<br>";
echo "The object is: {$userDataTest11}<br>";
?>

<h2>It should have an error when the email isnt in the format (xxx) xxx - xxxx</h2>
<?php 
$invalidUser = array("userName" => "Thugnificent", "picture" => "../images/thugnificent.jpg", "firstName" => "Otis", "lastName" => "Jenkins", "address" => "123 Thug Lane", "neighborhood" => "Woodcrest", "dateOfBirth" => "1989-01", "gender" => "male", "comedy" => "checked", "email" => "thugnasty@gmail.com", "phone" => "2105555555", "url" => "https://otis_jenkins/facebook.com");
$userDataTest12 = new UserData($invalidUser);
$test2 = empty($userDataTest12->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>';
echo $test2;
echo "The error for phone is: " . $userDataTest12->getError('phone') . "<br>";
echo "The object is: {$userDataTest12}<br>";
?>

<h2>It should have an error when the url isnt in the format http:// or https://text.com</h2>
<?php 
$invalidUser = array("userName" => "Thugnificent", "picture" => "../images/thugnificent.jpg", "firstName" => "Otis", "lastName" => "Jenkins", "address" => "123 Thug Lane", "neighborhood" => "Woodcrest", "dateOfBirth" => "1989-01", "gender" => "male", "comedy" => "checked", "email" => "thugnasty@gmail.com", "phone" => "(210) 555 - 5555", "url" => "otis_jenkins/facebook.com");
$userDataTest13 = new UserData($invalidUser);
$test2 = empty($userDataTest13->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>';
echo $test2;
echo "The error for url is: " . $userDataTest13->getError('url') . "<br>";
echo "The object is: {$userDataTest13}<br>";
?>
</body>
</html>
开发者ID:raroseman,项目名称:cs4413-Hoodflix,代码行数:30,代码来源:UserData_test.php

示例2: array

<h2>It should have an error when the phone number is invalid</h2>
<?php 
$invalidPhoneTest = array("phone" => "abc-def-ghij");
$s12 = new UserData($invalidPhoneTest);
$test12 = empty($s12->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>';
echo $test12;
echo "The error for phone is: " . $s12->getError('phone') . "<br>";
echo "The object is: {$s12}<br>";
?>

<h2>It should have an error when the favorite color is empty</h2>
<?php 
$invalidFavColorTest = array("fav_color" => "");
$s13 = new UserData($invalidFavColorTest);
$test13 = empty($s13->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>';
echo $test13;
echo "The error for fav_color is: " . $s13->getError('fav_color') . "<br>";
echo "The object is: {$s13}<br>";
?>

<h2>It should have an error when the favorite color is invalid</h2>
<?php 
$invalidFavColorTest = array("fav_color" => "#xyz123");
$s14 = new UserData($invalidFavColorTest);
$test14 = empty($s14->getErrors()) ? '' : 'Failed:It should have errors when invalid input is provided<br>';
echo $test14;
echo "The error for fav_color is: " . $s14->getError('fav_color') . "<br>";
echo "The object is: {$s14}<br>";
?>
</body>
</html>
开发者ID:mr-augustine,项目名称:sensor-data-repo,代码行数:31,代码来源:UserData_tests.php


注:本文中的UserData::getError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。