Illegal String Offset and Validation not working in PHP - php

I'm making a validation system for my website. Well actually, my code works if I didn't put any parameter in my $_POST(like$_POST['Login']). If I put any parameter in my $_POST, it returns an error:
Warning: Illegal string offset: 'username' in C:\ ...
My sample authentication form:
<form action="" method="post">
<div class="field">
<label for="username">Username: </label>
<input type="text" name="username" id="username" autocomplete="off" />
</div>
<div class="field">
<label for="Password">Password: </label>
<input type="password" name="password" id="password" autocomplete="off" />
</div>
<div class="field">
<label for="remember">
<input type="checkbox" name="remember" id="remember" value="on"/> Remember Me
</label>
</div>
<input type="hidden" name="token" value="<?php echo Token::generate(); ?>" />
<input type="submit" value="Login" name="Login"/>
</form>
The script that will be processed if the form was submitted:
<?php
require_once 'init.php';
$user = new User();
if($user->isLoggedIn()){
Redirect::to('index.php');
}
$validate = new Validate();
if(Input::exists()) {
if(Token::check(Input::get('token'))) {
$validation = $validate->check($_POST["Login"], array(
'username' => array('required' => true),
'password' => array('required' => true)
));
}
}
?>
The validation class:
<?php
class Validate {
# Set the variables
private $_passed = false,
$_errors = array(),
$_db = null;
# Construct or establish connection to the database
public function __construct(){
$this->_db = Database::getInstance();
}
# The validation/checking code or the main brain of the code
public function check($source, $items = array()){
# Run a ` for each ` for each item in the fields
foreach($items as $item => $rules) {
# Run a ` for each ` for every rule in the items
foreach($rules as $rule => $rule_value) {
# Set the variables of `value` and `item`
$value = $source[$item];
$item = sanitize($item);
if($rule === 'required' && empty($value)) {
$this->addError("{$item} is required");
} else if (!empty($value)) {
switch($rule) {
# Case: Minimum
case 'min':
if(strlen($value) < $rule_value) {
$this->addError("{$item} must be a minimum of {$rule_value} characters.");
}
break;
# Case Maximum
case 'max':
if(strlen($value) > $rule_value) {
$this->addError("{$item} must be a maximum of {$rule_value} characters.");
}
break;
# Case: Match
case 'matches':
if($value != $source[$rule_value]) {
$this->addError("{$rule_value} must match {$item}.");
}
break;
# Case: Unique
case 'unique':
$check = $this->_db->get($rule_value, array($item, '=', $value));
if($check->count()) {
$this->addError("{$item} already exists.");
}
break;
# Case: Not match
case 'notmatch':
if($value === $source[$rule_value]) {
$this->addError("{$rule_value} must not match {$item}.");
}
break;
}
}
}
}
if(empty($this->_errors)) {
$this->_passed = true;
}
}
# ~ ADD ~ and error
public function addError($error) {
$this->_errors[] = $error;
}
# ~ RETURN ~ the errors
public function errors() {
return $this->_errors;
}
# ~ CHECK ~ if it is passed
public function passed() {
return $this->_passed;
}
}

You are calling $validate->check and passing it $_POST["Login"] as first argument but based on your HTML you should be passing only $_POST. When you pass $_POST["Login"] then the form inputs should have attribute name as name="Login[username]" .
Right now when you pass $_POST["Login"] its actually an empty array so that could be the reason why you are getting Illegal string offset

Related

form validation using oop php

I want to validate a form using php by object oriented technique. I created a class validator by watching a tutorial but I want to add more rules in this class such as regular expressions and a number check and email check. Also the password must be eight to five characters in length with one being upper case and one lower case etc. But I can't add more rules in this class.
I added a max length rule but it is not working.
<?php
class Validator {
// for form fields storing
private $fields = array();
//for storing errors for form fields
private $field_errors = array();
private $form_is_valid = true;
public function add_field($field_name){
$this->fields[]= $field_name;
//associative array6
$this->field_errors[$field_name] = array();
}
public function add_rule_to_field( $field_name, $field_rule){
$rule_name = $field_rule[0];
switch ($rule_name)
{
case 'min_length':
if (strlen($_POST[$field_name]) < $field_rule[1]){
$this->add_error_to_field($field_name, ucwords($field_name). " cannot be less than {$field_rule[1]} in length");
//echo "must 1 chr <br>";
}
break;
case 'empty':
if(strlen($_POST[$field_name]) == 0){
$this->add_error_to_field($field_name, ucwords($field_name). " cannot be empty");
//echo "not empty <br>";
}
break;
case 'max_legnth':
if(strlen($_POST[$field_name]) > $field_rule[2]){
$this->add_error_to_field($field_name, ucwords($field_name). " cannot be greater then {$field_rule[2]} in length");
}
break;
default:
break;
}
}
private function add_error_to_field($field_name, $error_message){
$this->form_is_valid = false;
$this->form_is_valid ;
$this->field_errors[$field_name][] = $error_message;
//echo "add error to filed is working <br>";
}
public function form_valid(){
return $this->form_is_valid;
}
public function out_field_error($field_name){
if (isset($this->field_errors[$field_name])){
//echo "out ";
foreach ($this->field_errors[$field_name] as $field_errors){
echo "<p class='error'> {$field_errors} </p>";
//echo "out is running";
}
}
}
}
?>
Here is my form and object instance of the class:
<?php
require_once('validator.php');
$validator = new Validator;
if(isset($_POST['submit'])){
$validator->add_field('name');
$validator->add_rule_to_field('name', array('min_length', 5));
$validator->add_rule_to_field('name', array('empty'));
$validator->add_field('email');
$validator->add_rule_to_field('email', array('min_length', 6));
$validator->add_rule_to_field('email', array('empty'));
$validator->add_field('number');
$validator->add_rule_to_field('number', array('min_length', 8));
$validator->add_rule_to_field('number', array('empty'));
$validator->add_rule_to_field('number', array('max_length', 10));
$validator->add_field('password');
$validator->add_rule_to_field('password', array('min_length', 8));
$validator->add_rule_to_field('password', array('empty'));
$validator->filed_out();
if ($validator->form_valid() == true){
echo " registration is sucessfull";
exit();
}
// else{
// echo "form is not valid";
// //exit();
// }
}
?>
<form method="POST" id="form-add" action="">
<label>Name:</label>
<input type="text" name="name" value=""/>
<span> <?php $validator->out_field_error('name'); ?></span>
<label>Email:</label>
<input type="text" name="email" value=""/>
<span><?php $validator->out_field_error('email'); ?></span>
<label>Number:</label>
<input type="text" name="number" value=""/>
<span><?php $validator->out_field_error('number'); ?></span>
<label>Password:</label>
<input type="text" name="password" value=""/>
<span><?php $validator->out_field_error('password'); ?></span>
<label>Re Enter Password:</label>
<input type="text" name="cpassword" value=""/>
<span></span>
<input type="submit" name="submit" value="SUBMIT"/>
</form>
The $rule_name in the switch case is "max_legnth" but should be "max_length". So you never fall in this case.
Your "max_length" rule use the index 2, instead of the index 1, because $field_rule is defined as array('max_length', 10). So you have an "undefined index" notice.
The code of the rule :
case 'max_length':
if(strlen($_POST[$field_name]) > $field_rule[1]){
$this->add_error_to_field($field_name, ucwords($field_name). " cannot be greater then {$field_rule[1]} in length");
}
break;

Php registration error validation

I have been practicing with PHP and mongodb. I am developing a simple web application but using OOP.
I created a class called user which has my methods to do with user like addUser, deleteUser etc. For add user, I would like for the form to carry out some simple validation tasks, but i am not sure how. Here is the class to add a new user:
function createUser($username, $name, $email, $password){
$user = array(
'username' => $username,
'name' => $name,
'email' => $email,
'password' => $password
);
if ($this->db->count(array('username' => $username)) == 0) {
$this->db->insert($user);
return true;
} else {
echo 'username taken';
}
}
And the html:
<?php
session_start();
include_once 'user.php';
include './templates/header.php';
if (isset($_POST['register']) && ($_POST['register']) == ($_POST["register"])) {
$user = new User();
$return = $user->createUser(
$_POST['username'],
$_POST['name'],
$_POST['email'],
$_POST['password'],
$_POST['password2']);
}
if ($return == true) {
echo 'you have successfully registered';
} else {
echo '</br>' . 'sorry, try again';
}
?>
<div class="container">
<div class="jumbotron">
<form method="post" action="">
<label>Username: </label><br>
<input name="username" type="text" ><br><br>
<label>Name: </label><br>
<input name="name" type="text"><br><br>
<label>Email: </label><br>
<input name="email" type="email" ><br><br>
<label>Password: </label><br>
<input name="password" type="password" ><br><br><br>
<label>Repeat Password: </label><br>
<input name="password2" type="password" ><br><br><br>
<input name="register" class="btn btn-primary btn-lg" type="submit" value="Register"><br>
</form>
</div>
</div>
Please feel free to correct me on other mistakes you may notice. I know there is bound to be some.
i wrote a simple example for you its simple and useful
class validation {
public $currentValue;
public $values = array();
public $errors = array();
public function __construct() {
parent::__construct();
// echo "burasi model sayfasi ";
}
public function post($key){
if(isset($_POST[$key])){
$this->values[$key] = $_POST[$key];
$this->currentValue = $key;
return $this;
}else{ die("hi boo boo ! your form values are empty");}
}
public function isEmpty(){
if(empty($this->values[$this->currentValue])){
$message='the form is emppty';
$this->errors[$this->currentValue]['empty'] =''.$message.'';
}
return $this;
}
public function submit(){
if(empty($this->errors)){
return true;
}else{
return false;
}
}
}
this is an example so how can you use it ?
firstly you need yo call the class
$form = new validation ();
$form->post("all you need just write post name here ")
->isEmpty();
if($form->submit()){
//everyting is ok !
you cann add delet or update data
}else{
$data["error"] = $form->errors; // and we sett the errorr mesages to the array now you can show the user the errormesages ! well done
}
}

Display Php form errors next to fields

I looked in the forum for similar questions but could not find anything that would help me.
I have the validation class that validates form entries. But It displays them at the top of the table. How could I display these next to the fields rather then top of the form?
Registration.php
if(Input::exists()){
$validate = new Validate();
$validation = $validate->check($_POST, array(
'fullName' => array(
'required' => true,
'min' => 4,
'max' => 20
),
'username' => array(
'required' => true,
'min' => 4,
'max' => 20,
'unique' => 'user'
),
'email' => array(
'required' => true,
'unique' => 'user'
),
'password' => array(
'required' => true,
'min' => 6
),
'password_again' => array(
'required' => true,
'matches' => 'password'
)
));
if($validation->passed()){
// Register User
echo('Passed');
} else {
// Output Errors
foreach($validation->errors() as $error){
echo $error, '</br>';
}
}
}
?>
<div class="registration">
<h3> Register with WebA<font style="color: #c14a44;">ww</font>ards </h3>
<p> Spare us few little seconds, and you'll be glad you did. </p>
<form method="post" action="">
<input type="text" id="fullName" value="<?php echo escape(Input::get('fullName')); ?>" name="fullName" placeholder="Your Full name">
<input type="text" id="username" value="<?php echo escape(Input::get('username')); ?>" name="username" placeholder="Choose Username" autocomplete="off">
<input type="email" id="email" value="<?php echo escape(Input::get('email')); ?>" name="email" placeholder="Email address">
<input type="password" id="password" name="password" placeholder="Password">
<input type="password" id="password_again" name="password_again" placeholder="Comfirm password">
<input id="gobutton" type="submit" value="Register">
</form>
Validate.php
public function check($source, $items = array()){
foreach($items as $item => $rules){
foreach($rules as $rule => $rule_value){
$value = trim($source[$item]);
$item = escape($item);
// if rule is required and value is empty add error
if($rule === 'required' && empty($value)){
$this->addError("{$item} is required");
} else if(!empty($value)) {
// DEFINE THE RULES FOR VALIDATION MIN, MAX
// USE SWITCH STATEMENT TO SWITCH BETWEEN THE RULES AND CHECK IF VALID
// Case for each of the rules defined on the form
switch($rule){
case 'min':
if(strlen($value) < $rule_value){
$this->addError("{$item} must be a minimum of {$rule_value} characters.");
}
break;
case 'max':
if(strlen($value) > $rule_value){
$this->addError("{$item} must be a maximum of {$rule_value} characters.");
}
break;
case 'matches':
if($value != $source[$rule_value]){
$this->addError("{$rule_value} must match {$item}");
}
break;
case 'unique':
$check = $this->_db->get($rule_value, array($item, '=', $value));
if($check->count()){
$this->addError("{$item} already exists.");
}
break;
}
}
}
}
if(empty($this->_errors)){
$this->_passed = true;
}
return $this;
}
You write code that puts those errors where you want them.
<?php
$errors = array();
if (!$something) {
$errors['field'] = 'Message';
}
?>
<? if (isset($errors['field'])) : ?>
<p class="error"><?php echo $errors['field']; ?></p>
<?php endif; ?>
<input type="text" name="field" ...>
Without seeing more of your code I can't tell (the addError method isn't included), but your validation class doesn't appear to have an easy way of associating an error with a field in the response (it's just a single string), so it will need some work to do this. I would suggest returning the errors as an associative array, with the key being the name of the field, and the value being the error message to be printed, and leave it blank for fields that are correct. Then, in your registration file, you can easily refer to the field in question.
You have to iterate through the errors while you are outputting the fields, check for errors related to that field, and print them after outputting the inputs, instead of echoing all the errors above the form.
The errors array should be multidimensional, if you need to have more than one validation error in each field. You should have an array with an entry for each field name.
You would also need the fields to be an array to achieve this.
This way you could do something like this (untested):
foreach ($field as $f) {
echo "<input type='{$f->type}' id='{$f->name}' value='{$f->value}' name='{$f->name}' placeholder='{$f->description}'>";
if (in_array($f->name, $errors)) {
echo "<span class='errors'>{$errors[$f->name]}</span>";
}
}
If the error entry for each field is an array, you would have to iterate through it before echoing the errors.

php Illegal offset type in isset or empty

I have this code that was working initially, but does not work after I restarted my computer.
The error I am getting is:
Warning: Illegal offset type in isset or empty in D:\xampp\htdocs\cookieboylive\classes\Session.php on line 4
There's 3 files on my site - Index, Login, Register. Index page checks if users is logged in, but I don't think it has anything to do with the problem.
Here's the current code:
The main register/login.php page
require_once 'core/init.php';
if(Input::exists()) {
if(Token::check(Input::get('token'))) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
'username' => array('required' => true),
'password' => array('required' => true)
));
if($validation->passed()) {
$user = new User();
$login = $user->login(Input::get('username'), Input::get('password'));
if($login) {
Redirect::to('index.php');
} else {
echo '<p>Sorry, login failed.</p>';
}
} else {
foreach($validation->errors() as $error) {
echo $error, '<br>';
}
}
}
}
if(Input::exists()) {
if(Token::check(Input::get('token'))) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
'username' => array(
'required' => true,
'min' => 2,
'max' => 20,
'unique' => 'users'
),
'password' => array(
'required' => true,
'min' => 6
),
'password_again' => array(
'required' => true,
'matches' => 'password'
),
'name' => array(
'required' => true,
'min' => 2,
'max' => 50
)
));
if($validation->passed()) {
$user = new User();
$salt = Hash::salt(32);
try {
$user->create(array(
'username' => Input::get('username'),
'password' => Hash::make(Input::get('password'), $salt),
'salt' => $salt,
'name' => Input::get('name'),
'joined' => date('Y-m-d H:i:s'),
'group' => 1
));
Session::flash('home', 'Register SUCCESS');
Redirect::to('index.php');
} catch(Exception $e) {
die($e->getMessage());
}
} else {
foreach($validation->errors() as $error) {
echo $error, '<br>';
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="styles/register_login_styles.css">
<link rel="stylesheet" type="text/css" href="styles/animate-custom.css">
</head>
<body>
<div class="container">
<div id="container_demo" >
<a class="hiddenanchor" id="toregister"></a>
<a class="hiddenanchor" id="tologin"></a>
<div id="wrapper">
<div id="login" class="animate form">
<form action="" method="post">
<div class="field">
<h1>Log in</h1>
<p>
<label for="username" class="uname" data-icon="u" >Username </label>
<input id="username" name="username" required="required" type="text" placeholder="Username" autocomplete="off">
</p>
<p>
<label for="password" class="youpasswd" data-icon="p">Password </label>
<input id="password" name="password" required="required" type="password" placeholder="Password">
</p>
<p class="keeplogin">
<input type="checkbox" name="loginkeeping" id="loginkeeping" value="loginkeeping">
<label for="loginkeeping">Keep me logged in</label>
</p>
<input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
<p class="login button">
<input type="submit" value="Login">
</p>
<p class="change_link">
Not a member yet ?
Join us
</p>
</form>
</div>
</div>
<div id="register" class="animate form">
<form action="" method="post">
<h1> Sign up </h1>
<p>
<label for="username" class="uname" data-icon="u">Username</label>
<input id="username" value="<?php echo escape(Input::get('username')); ?>" name="username" required="required" type="text" placeholder="Username" autocomplete="off">
</p>
<p>
<label for="password" class="youpasswd" data-icon="p">Your password </label>
<input id="password" name="password" required="required" type="password" placeholder="Password">
</p>
<p>
<label for="password_again" class="youpasswd" data-icon="p">Please confirm your password </label>
<input id="password_again" name="password_again" required="required" type="password" placeholder="Password again">
</p>
<p>
<label for="name" class="youmail" data-icon="n" >Name</label>
<input id="name" name="name" value="<?php echo escape(Input::get('name')); ?>" required="required" type="text" placeholder="Name" autocomplete="off">
</p>
<input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
<p class="signin button">
<input type="submit" value="Sign up">
</p>
<p class="change_link">
Already a member ?
Go and log in
</p>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
Session.php
<?php
class Session {
public static function exists($name) {
return (isset($_SESSION[$name])) ? true : false;
}
public static function put($name, $value) {
return $_SESSION[$name] = $value;
}
public static function get($name) {
return $_SESSION[$name];
}
public static function delete($name) {
if(self::exists($name)) {
unset($_SESSION[$name]);
}
}
public static function flash($name, $string = '') {
if(self::exists($name)) {
$session = self::get($name);
self::delete($name);
return $session;
} else {
self::put($name, $string);
}
}
}
User.php
<?php
class User {
private $_db,
$_data,
$_sessionName,
$_isLoggedIn;
public function __construct($user = null) {
$this->_db = DB::getInstance();
$this->_sessionName = Config::get('session/session_name');
if(!$user) {
if(Session::exists($this->_sessionName)) {
$user = Session::get($this->_sessionName);
if($this->find($user)) {
$this->_isLoggedIn = true;
} else {
// Pr0cess logout
}
} else {
$this->find($user);
}
}
}
public function create($fields = array()) {
if(!$this->_db->insert('users', $fields)) {
throw new Exception('There was a problem creating an account.');
}
}
public function find($user = null) {
if($user) {
$field = (is_numeric($user)) ? 'id' : 'username';
$data = $this->_db->get('users', array($field, '=', $user));
if($data->count()) {
$this->_data = $data->first();
return true;
}
}
return false;
}
public function login($username = null, $password = null) {
$user = $this->find($username);
if($user) {
if($this->data()->password === Hash::make($password, $this->data()->salt)) {
Session::put($this->_sessionName, $this->data()->id);
return true;
}
}
return false;
}
public function data() {
return $this->_data;
}
public function isLoggedIn() {
return $this->_isLoggedIn;
}
}
I'm getting Fatal error: DEBUG: array ...
That means $name is an array, which is obviously an illegal string offset. $_SESSION[array()] does not work. Make sure you're passing the right value to Session::exists().
I tried most of the solutions suggested above. In actual fact the answer is not in the spelling but is in the fact that, as was pointed out above, the $name variable in the exists function is actually an array.
public static function exists($name) {
return (isset($_SESSION[$name])) ? true : false;
}
The simple fix is to append [0] to [$name] so it becomes [$name][0] which returns the value associated with it and the one you want to see. Works for me. Why it worked in the video, I can't figure out; may be a configuration thing.
I recognize the context you are dealing with, a tutorial PHP login/registration project from Skillfeed. In fact I had the very same error that led me to a google search on the same error - I ended on this stackoverflow thread by You.
I couldn't find the answers very helpful but I looked through the classes of my project and I found the source of my problem in another class than your 3 classes shown in here.
That is in Token.php :
public static function check($token){
$tokenName = Config::get('sesson/token_name');
if(Session::exists($tokenName) && $token === Session::get($tokenName)){
Session::delete($tokenName);
return true;
}
return false;
}
The problem was a simple misspelling , notice the get() function with its string parameter 'sesson/token_name', it should have been 'session/token_name'. Once I fixed this it worked for me!
It simply means the type of the variable (int, bool, array,..) you are passing does not aligns with expected parameter type in empty or isset.
You have not typed the $name variable and that`s should be problem.
Try this which will check also $name variable:
return !empty($name) && is_string($name) && isset($_SESSION[$name]) ? true : false;
Just play with some situations or implement typing into you code.
"Warning: Illegal offset type in isset or empty" may be shown if key-variable is not string. Example:
foreach ($xml->attributes() as $attrname => $attrval)
{
if($attrname == "Name") $Name = $attrval;
if(isset($_GET[$Name])) //catch Warning
...
Because gettype($Name) --> object.
Use type conversion to string:
if(isset((string)$_GET[$Name])) //pass Perfect

php validation not working

I am developing a simple registration form that validates with php. problem is rather than the validation echoing on screen once I click the submit button nothing happens, no error or brake it dose not show me what the error is, I believe my logic is correct but I believe there may be a mistake.
would appriciate any advise or identification of my problem
register.php
<?php
require_once 'core/init.php';
if(Input::exists()) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
'username' => array(
'required' => true,
'min' => 2,
'max' => 20,
'unique' => 'users'
),
'password' => array(
'required' => true,
'min' => 6
),
'password_again' => array(
'required' => true,
'matches' => 'password'
),
'name' => array(
'required' => true,
'min' => 2,
'max' => 50
),
));
if($validation->passed()) {
echo 'Passed';
} else {
print_r($validation->errors());
}
}
?>
<form action="" methord="post">
<div class="field">
<lable for="username">Username</lable>
<input type="text" name="username" id="username" value="<?php echo escape(Input::get('username')); ?>" autocomplete="off">
</div>
<div class="field">
<lable for="password">Choose Your Password</lable>
<input type="password" name="password" id="password">
</div>
<div class="field">
<lable for="password_again">Verify Password</lable>
<input type="password" name="password_again" id="password_again">
</div>
<div class="field">
<lable for="name">Your Name</lable>
<input type="text" name="name" value="<?php echo escape (Input::get('name')); ?>" id="name">
</div>
<input type="submit" value="Register">
</form>
Validation.php
<?php
class Validate {
private $_passed = false,
$_errors = array(),
$_db = null;
public function __contruct() {
$this->_db = DB::getInstance();
}
public function check($source, $items = array()) {
foreach($items as $item => $rules) {
foreach($rules as $rule => $rule_value) {
$value = $source[$item];
if($rule == 'required' && empty($value)) {
$this->addError("{$item} is required")
} else {
}
}
}
if(empty($this->_errors)) {
$this->_passed = true;
}
return $this;
}
private function addError() {
$this->_errors[] = $error;
}
public function errors() {
return $this->_errors;
}
public function passed() {
return $this->_passed;
}
}
UPDATE
Have corrected typo that was correctly pointed out by #PeteR, but there is still a problem that the echo validation is not printing out.
Link to form
http://stuweb.cms.gre.ac.uk/~ob219/membership/register.php
Looks like you have a typo, fella.
if($rule == 'requierd' && empty($value)) {
You also have a semicolon missing here:
$this->addError("{$item} is required");
----^
And another typo:
<form action="" methord="post">
Should be method...
And finally, try this:
private function addError($error) {
Input::exists()
returns false/null or contains errors, thus, the if statement is not true
if(Input::exists()) {
and the code inside of it (validation) does never get executed.
Debug with
print_r(Input::exists());
You should also change your if to a real condition:
if(Input::exists() === true) {
Enable error reporting in PHP (from http://blog.flowl.info/2013/enable-display-php-errors/)
<?php
// Put these lines to the top of your script
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
ini_set('xmlrpc_errors', true);
Update - Yet another one:
private function addError() {
$this->_errors[] = $error;
}
Method has no parameters..
private function addError($error) {
$this->_errors[] = $error;
}

Categories