how to run the function on load of my php without using jscript?

628

I want to display the output inside the class I declare by calling the function I declared inside it. How do I do that?

<?php

class Testscript3
{
private $var_a;
private $var_b;
private $var_c;
private $var_d;

function test1()
{
$this->var_a= array(256,376,129);
$this->var_c= 7;
$this->var_e="GLOBALVARIABLE";
}

function test2($param1)
{
$nwvar1=($param1 * 11)+2;
$nwvar2=substr($nwvar1,0,1);

return $nwvar2;
}

function performer()
{
  $this->test1();

$this->var_b = $this->var_a;

$arr_1= $this->var_a;
$arr_2= $this->var_b;

$rowComp=0;

echo"<html><body>";
echo"<table border=1>";

for($aa=0; $aa< count($arr_1);$aa++)
{

for($aa=0; $bb< count($arr_1);$bb++)
{
$rowComp=($arr_1[$aa] +$arr_2[$bb]) + $this->test2((7+ $bb)* $arr_2[$bb]);

echo"<tr>";
echo"<td>$arr_1[$aa]";
echo"<td>$arr_1[$bb]";
echo"<td>$rowComp";
echo"<td>";

if ($bb==0)
{
echo "A";
}
else
{
echo "$this->strtolower(substr($var_e, $aa, $bb))";
}


echo"</td>";
echo"</tr>";
}

}
echo"</table>";
echo"</body>";
echo"</html>";
}

performer();
}

?>

I want to see the value of the output I made. How do I call the function inside the class?

516

Answer

Solution:

To call a function of a class:

class MyClass {
  public function test() {
    echo "Output something";
  }
}

$o = new MyClass();
$o->test(); // Calls the function

People are also looking for solutions to the problem: php - Fetch DPI from JPEG without library returns incorrect result

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.