TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-06-2012, 03:21 AM   #1 (permalink)
The Visitor
Newcomer 
 
Join Date: Dec 2011
Posts: 1
Thanks: 0
rawprogrammer is on a distinguished road
Unhappy print_r noting happen with my class

i build new class to loop field html but when i print_r it nothing "FeildHTML Object ( )"
here my code

class FeildHTML
{
public function setFeildCheck ($field,$fieldval,$unsetbutton)
{
$field = array($field);
$fieldval = array($fieldval);
$label = array_combine($field,$fieldval);
unset($_POST [$unsetbutton]);
foreach($_POST as $k=>$v)
{
$$key = $v;
echo $label[$k]."=$v<br />";
}
}

}
$a = new FeildHTML();
$a->setFeildCheck('a','b','c');
print_r($a);
?>
rawprogrammer is offline  
Reply With Quote
Old 01-09-2012, 04:36 PM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

What were you expecting it would show? print_r would only show the properties in an object in this case. which the class doesn't, have a field. try adding a property and you would see the value print with print_r. like this:

PHP Code:
<?php
class FeildHTML
{
  public $state = 'not set'; //I added this property

  public function setFeildCheck ($field,$fieldval,$unsetbutton)
  {
    $field = array($field);
    $fieldval = array($fieldval);
    $label = array_combine($field,$fieldval);
    unset($_POST [$unsetbutton]);
    foreach($_POST as $k=>$v)
    {
      $$key = $v;
      echo $label[$k]."=$v<br />";
    }

    $this->state = 'set';
  }
}

$a = new FeildHTML();
$a->setFeildCheck('a','b','c');
print_r($a);
?>
//print_r output is this:
FeildHTML Object
(
    [state] => set
)
tony is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
base classes..... allworknoplay Absolute Beginners 16 05-10-2009 08:09 PM
A Generic Singleton Base Class Theo Advanced PHP Programming 7 08-18-2008 02:25 AM
[Tutorial] Basic tutorial about class basics Tanax Absolute Beginners 14 07-24-2008 01:37 PM
PHP5 Classes A to Z Part 1 quantumkangaroo Advanced PHP Programming 11 04-01-2008 04:21 AM
Tutorial: PHP and OOP, a beginners guide Village Idiot Tips & Tricks 0 09-06-2007 04:23 PM


All times are GMT. The time now is 09:39 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design