Class/functions question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I building a website with PHP.  I am going to be using functions to
deal with vaildation.  I am putting all the methods in a class called
Validation.  My problem is I do not know how to call the function. 
Well I shouldn't say that.  I know how to call functlions, I just just
don't know how to do it in PHP.  Let me put it this way.  When I write
programs in C++/Java I know that I have to do the following steps,

create an object reference to the class
use the object reference to access the methods.

I am almost certain that it is the same thing in PHP.  So this is what
I did in my web page.


<?php
if (isset($submit))
{
//validation code
class Validation
{
	function checkEmpty ($var)
	{
		if (empty($var))
		{
			echo "YEAH It works!!";
		}
	}
}

else
{?>
.....
<tr>
	<td align="left">First Name</td>
	<td align="left">
		<span class="color">*</span><input type="text" name="name" size="20">
		<?php
			$v = new Validation;
			$v->checkEmpty($_POST["name"]);
		?>
	</td>
</tr>
......

... = rest of php/html code

the else block holds the entire html code for the page

Do I have the logic right?

Paul

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux