. Rising Code Challenges Skip to main content

Posts

Showing posts from May, 2016

Form validation in codeigniter

This post will show validate a form in codeigniter. ci-validations Its necessary to validate your form to prevent user to upload any unwanted data. full validations description of codeIgniter create a controller and load the form validation library and helper form and url. $this->load->helper(array("form","url")); $this->load->library('form_validation'); and load your view. In view create a html form <form class="form-basic" method="post"> <input type="text" name="name"> <input type="text" name="email"> </form> and set rules for validate your form in controller $this->form_validation->set_rules('name', 'name', 'required'); $this->form_validation->set_rules('email', 'email', 'required|valid_email'); Run validations rule by if ($this->form_validation->run() == FALSE){ $this->pageData["...

What is static functions in php

This article describe the use of static function and their definition. After Declare a class or methods as static they can access without needing an instantiation of the class. Because static methods are callable without an instance of the object created, the pseudo-variable $this is not available inside the method declared as static. Simply, static functions function independently of the class where they belong. $this means, this is an object of this class. It does not apply to static functions Entire difference is, you don't get $this supplied inside the static function. If you try to use $this , you'll get a Fatal error: Using $this when not in object context. Caution In PHP 5, calling non-static methods statically generates an E_STRICT level warning. Warning In PHP 7, calling non-static methods statically is deprecated, and will generate an E_DEPRECATED warning. Support for calling non-static methods statically may be removed in the future. class Foo { public stati...