Test Forms Class - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Test Forms Class.php
- <?php
- class Clio_Users_Forms {
- protected $slug;
- protected $args = array(
- 'id' => '',
- 'name' => '',
- 'class' => '',
- 'type' => 'text',
- 'required' => '',
- 'value' => '',
- 'values' => array(),
- 'placeholder' => '',
- 'options' => array(),
- 'selected' => '',
- 'checked' => ''
- );
- public function get_attr( $args ) {
- $args = array_merge( $args, $this->args );
- foreach( $args as $key => $value ) {
- if( $value ) {
- $args[$key] = "{$key}=\"{$value}\"";
- }
- else {
- unset( $args[$key] );
- }
- }
- print_r( $args );
- return $args;
- }
- public function input( $args ) {
- $this->get_attr( $args );
- extract( $args );
- ob_start(); ?>
- <label for="<?php echo $name; ?>">
- <input type="<?php echo $type; ?>" name="<?php echo $name; ?>"
- </label>
- <?php return ob_get_clean();
- }
- }
- $args = array(
- 'name' => 'mon_nom',
- 'type' => 'text',
- 'value' => 'klk',
- );
- $inst = new Clio_Users_Forms();
- print_r( $inst-> get_attr( $args ));
File Description
- Test Forms Class
- PHP Code
- 15 Apr-2018
- 1.09 Kb
You can Share it:
Latest PHP Pastes