473,808 Members | 2,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

clearer post to method/property/class problem - help appreciated

<?
class ErrorMsgCollect ion {

var $name;
var $mandatory;
var $emptyErr;
var $maxLength;
var $maxLengthErr;
var $minLength;
var $minLenghtErr;
var $pattern;
var $patternErr;
var $arrayMandatory AmountType;
var $validArrayErr;
var $isAssoc;
var $erroredArrayAs socIndexArray;

function ErrorMsgCollect ion() {
$this->name = '';
$this->arrayMandatory AmountType = ''; // DEFAULT TO NULL
$this->validArrayEr r = $emptyErr; // DEFAULT TO SAME ERROR MSG AS
EMPTY ERR MSG
$this->assocIndex = 0; // DEFAULT TO 0 WILL BE USED AS INDEX KEY FOR
CONVERTING ERR ARRAY (IF INDICATED) TO ASSOCIATIVE
$this->erroredArrayAs socIndexArray = array();
return true;
}

function getErroredArray AssocIndex($key ) {
return $this->erroredArrayAs socIndexArray[$key];
}
function getEmptyErr() {
if ($this->getIsAssoc() ) return $this->emptyErr . '~IsAssoc~' .
str_replace('~' , '~',
$this->getErroredArra yAssocIndex($th is->name));
return $this->emptyErr;
}

function getIsAssoc() {
return $this->isAssoc;
}

function getMandatory() {
return $this->mandatory;
}

function getMaxLength() {
return $this->maxLength;
}

function getMaxLengthErr () {
if ($this->getIsAssoc() ) return $this->emptyErr . '~IsAssoc~' .
str_replace('~' , '~',
$this->getErroredArra yAssocIndex($th is->name));
return $this->maxLengthErr ;
}

function getMinLength() {
return $this->minLength;
}

function getMinLengthErr () {
if ($this->getIsAssoc() ) return $this->emptyErr . '~IsAssoc~' .
str_replace('~' , '~',
$this->getErroredArra yAssocIndex($th is->name));
return $this->minLengthErr ;
}

function getName() {
return $this->name;
}

function getPattern() {
return $this->pattern;
}

function getPatternErr() {
if ($this->getIsAssoc() ) return $this->emptyErr . '~IsAssoc~' .
str_replace('~' , '~',
$this->getErroredArra yAssocIndex($th is->name));
return $this->patternErr;
}

function getValidArray() {
return $this->arrayMandatory AmountType;
}

function getValidArrayEr r() {
if ($this->getIsAssoc() ) return $this->emptyErr . '~IsAssoc~' .
str_replace('~' , '~',
$this->getErroredArra yAssocIndex($th is->name));
return $this->validArrayEr r;
}

function setErroredArray AssocIndex($arr ayName, $assocIndex) {
$this->erroredArrayAs socIndexArray =
$this->erroredArrayAs socIndexArray + array($arrayNam e => $assocIndex);
}

function setIsAssoc($isA ssoc) {
$this->isAssoc = $isAssoc;
}
function setMandatory($m andatory,$empty Err) {
$this->mandatory = $mandatory;
$this->emptyErr = $emptyErr;
}

function setMaxLength($m axLength,$maxLe ngthErr) {
$this->maxLength = $maxLength;
$this->maxLengthErr = $maxLengthErr;
}

function setMinLength($m inLength,$minLe ngthErr) {
$this->minLength = $minLength;
$this->minLengthErr = $minLengthErr;
}

function setName($name) {
$this->name = $name;
}

function setPattern($pat tern,$patternEr r) {
$this->pattern = $pattern;
$this->patternErr = $patternErr;
}

function setValidArray($ arrayMandatoryA mountType,$vali dArrayErr) {
$this->arrayMandatory AmountType = $arrayMandatory AmountType;
$this->validArrayEr r = $validArrayErr;
}
}

class FormValidator {

// $errormsgObjArr ay WILL BE AN ARRAY OF ErrorMsgCollect ion OBJECTS

var $validator, $errors, $isValid;
var $post, $errorMsgObjArr ay, $dateFormFields Array;

function FormValidator($ post, $errorMsgObjArr ay, $dateFormFields Array
= array()) {
$this->validator = null;
$this->errors = array();
$this->isValid = true;
$this->post = $post;
$this->errorMsgObjArr ay =& $errorMsgObjArr ay;
$this->dateFormFields Array = $dateFormFields Array;
}

function getErrorArray() {
return $this->errors;
}

function isValid() {
foreach ($this->errorMsgObjArr ay as $key => $val) {
print_r(get_cla ss_methods($val )); print_r("<P>");
print_r($val->name . "<P>");
print_r($val->getName() . "<P>");
}
return $this->isValid;
}

}
?>

The first print_r works, it produces an array of methods including
"getName".

The second print_r works, it produces the value of $val->name being
"Whatever" or something.

The third print_r fails, and here is the error:

Fatal error: Call to a member function on a non-object in
/var/www/html/development/phillip/libdev/formvalidation. inc on line
150

I am totally baffled as to this behavior because it makes absolutely
no sense to me, no matter what I have read about classes, this makes
no sense at all. How can a class object suddenly NOT become an object
by the next line?

Phil
Jul 17 '05 #1
1 1886
Hi Phil!

(...)

function isValid() {
foreach ($this->errorMsgObjArr ay as $key => $val) {
print_r(get_cla ss_methods($val )); print_r("<P>");
print_r($val->name . "<P>");
print_r($val->getName() . "<P>");
}
return $this->isValid;
}

}
?>

The first print_r works, it produces an array of methods including
"getName".

The second print_r works, it produces the value of $val->name being
"Whatever" or something.

The third print_r fails, and here is the error:

Fatal error: Call to a member function on a non-object in
/var/www/html/development/phillip/libdev/formvalidation. inc on line
150

I am totally baffled as to this behavior because it makes absolutely
no sense to me, no matter what I have read about classes, this makes
no sense at all. How can a class object suddenly NOT become an object
by the next line?


It doesn't have to be an object in the second line. If it is not
defined at this point, PHP will create one with name as a property.

Try

error-reporting(E_ALL );, this may give you an undefined property on
the second one.

And print_r ($val);
HTH ,jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4199
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens in IE as well as FireFox. This code has been tested on a Win2003 server, IIS6, PHP 5.0.3, mySQL 4.1.8 and it works fine. The problem server is a Win2k server, IIS5, PHP 5.0.4, mySQL 4.1.11.
7
15602
by: Edward Diener | last post by:
This simple code example gives me the message, "TypeError: 'staticmethod' object is not callable". class X(object): def Y(x): print x Y = staticmethod(Y) ad = { 1 : Y } def Z(self): self.ad(3)
0
1601
by: Lucas, Todd | last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing for a Menu. I've been at it for about 3 weeks now, and can't seem to get around this problem. So I'm hoping that someone can help me ... My environment: VS 2003 v7.1.3088, Win2K v5.0.2195 SP3, IE6 v6.0.2800.1106 browser. I have a class (C3Menu) derived from WebControl, with a property (MenuItems) that is a collection of menu items. The collection property is...
8
5081
by: Gert | last post by:
Hi, I have a form (server side) because of the filling of variables through the application. But now I need to post it to an url on submit. My .HTML form looks like this, but how to translate it to asp.net vb code? !--<FORM ACTION="/test/test.php" METHOD=POST>--> <form action="https://multipay.net/transaction/mpmain.php" method="post"> ....
3
1560
by: Amin Sobati | last post by:
Hi, I have two classes. Class2 inhertis Class1: ----------------------------- Public Class Class1 Public Overridable Sub MySub() End Sub End Class Public Class Class2
3
6936
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication as per RFC 2617 (http://www.faqs.org/rfcs/rfc2617.html). My attempts to authenticate are failing. The server requires the header to be present with the request. For security reasons, it will not reply in any way if the header is not present. ...
4
3027
by: ms | last post by:
Something weird is going on here, an HttpHandler works perfectly, exect when I post a form to it using the post method it gives me an file not found 404 error, if I post to it using the get method works perfectly. Can someone help?? thanks in advance Jose Suero
2
2203
by: CindyH | last post by:
Hi Trying to get this code to work for http xml post. I need the post to be xml (doc.outerxml) sent in single key name as stream. The following is the post code and code for receiving the request. When it hits the "myresponse = myrequest.GetResponse()" in the post code - I'm getting following error: "The remote server returned an error: (500) Internal Server Error". I don't know if I have something wrong with the post or receiving it on...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10631
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.