class msgsys {
var $message;
function addmsg($msg) {
$message .= $msg;
echo $message;
}
function showmsg() {
echo $this->$message;
}
}
class formchk {
var $highlight = array();
function validchk($regval, $fieldval, $msg) {
if ( !preg_match($regval, $fieldval) ) { msgsys::addmsg($msg); }
}
}
<?PHP
if ( $_POST['submit'] == "Add" ) {
include ('msgsys_cls.php');
include ('formchk_cls.php');
$srtmsg = new msgsys;
$srtchk = new formchk;
$srtchk->getregex();
}
?>
<form action = "" method="post">
<table border="1" width="550px">
<tr>
<td colspan="2">
<?php echo 'Echoing out the messege!'; $srtmsg->showmsg(); ?>
</td>
The reason why I didn't use $this-> for $message .= $msg; in msgsys class because, in my formchk class i'm calling the addmsg in the msgsys class using ::. This works well, but for some reason $message .= $msg is not keeping the exsisting values while adding a new value.
Another issue i'm running into is, in my page code: <?php echo 'Echoing out the messege!'; $srtmsg->showmsg(); ?> is not out putting the message var.
Could anyone give me a hand with these two issues?
-Thanks