Re: Class/functions question
| From: | Chris Shiflett | Date: | Sun, 12 Feb 2006 12:28:02 +0000 |
| Subject: | Re: Class/functions question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-230265@lists.php.net to get a copy of this message | ||
Paul Goepfert wrote:
I know how to call functlions, I just just don't know how to do it in PHP.Based on the rest of your question, I think you mean methods, not functlions. :-) If you're struggling with syntax, you should take one step at a time. Try this: <?php class myClass {
function myMethod()
{
echo '<p>myMethod()</p>';
}
}
$myObject = new myClass;
$myObject->myMethod();
?>
That should help you with any syntax problems, but I suspect your problem has more to do with logic than with syntax.
if (isset($submit)) { class Validation {/* ... */
} } else {/* ... */
$v = new Validation; $v->checkEmpty($_POST["name"]);If the form is submitted, define the class, else use the class. That doesn't sound right... Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/