- Joined
- Sep 1, 2011
- Messages
- 453
- Reaction score
- 191
I still consider my self noob so, any input on how I can better myself is greatly appreciated!
mysql.class.php
Example of how it can be ran.
Outcome:
mysql.class.php
PHP:
<?php
///////////////////////////////////////////////////////Message Class (PHP) ////\\
//
//Copyright (C) 2012 Secured of RaGEZONE
//
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////Documentation ////\\
//7 Different Types of functions
//Usage: $doMesage->(*Type*, *Message*, *var1*, *var2, ect....);
//Types: 1:print, 2:printf, 3:vprintf, 4:sprintf, 5:print_r, 6:echo, 7:return
//Ex Code: $doMsg->("5", "Random Echo Message");
//Outcome: Random Echo Message
//Echos a Message and Returns the Added Message can be used with
//$var = "foo";
//$doMsg->("5", $var");
//Outcome: Foo
//////////////////////////////////////////////////////////////////////////////////
class Msg {
private $type;
private $msg;
private $status;
private $earlyF;
public function checkInvalidFormat($input)
{
//Some Errors
if($input <= 0)
{
$this->status=NULL;
} else {
$this->status=1;
}
}
public function checkStatus($Var)
{
if($Var==NULL)
{
$ei = debug_backtrace();
$this->earlyF = "Msg Class:: Incorrect Format. Using function " . $ei[0]['function'] . " on line " . $ei[0]['line'] . " in file " . $ei[0]['file'] . ".";
return false;
} else if ($Var==1) {
return true;
} else {
$ei = debug_backtrace();
$this->earlyF = "Msg Class:: Status Error. Using function " . $ei[0]['function'] . " on line " . $ei[0]['line'] . " in file " . $ei[0]['file'] . ".";
return false;
}
}
public function buildMsg($type, $message) {
if($type == "1")
{
print $message;
} else if($type == "2") {
printf($message);
} else if($type == "3") {
vprintf($message);
} else if($type == "4") {
printf($message);
} else if($type == "5") {
print_r($message);
} else if($type == "6") {
echo $message;
} else if($type == "7") {
return($message);
}
}
public function sMsg()
{
//Grab all arguments slice first argument into two for type and msg and convert to string
$arg = func_get_args();
$this->type = implode(array_slice($arg, 0, 1));
$this->msg = implode(array_slice($arg, 1));
//check format
$this->checkInvalidFormat($this->type);
//check status
if(!$this->checkStatus($this->status) == true)
{
$final=2;
} else {
$final=1;
}
if($final !=1) {
$this->buildMsg("5", $this->earlyF);
} else {
$this->buildMsg($this->type, $this->msg);
}
}
}
?>
Example of how it can be ran.
PHP:
<?php
//include
include_once "inc/class/msg.class.php";
//test vars
$var1 = "1";
$var2 = "2";
$var3 = "3";
$var4 = "4";
$var5 = "5";
//test functions
function dostuff()
{
$var6 = "stuff done!";
return $var6;
}
function dostuff2()
{
$var6 = "stuff done again!!";
return $var6;
}
$msg = New Msg;
$msg->sMsg("6", $var1, $var2, $var3, $var4, $var5, dostuff(), dostuff2());
?>
Outcome:
Code:
12345stuff done!stuff done again!!