how to send the value of a for from one php to another

1

I would like to know how I could send the value of $ sumatotal from this php to another

$Sumatotal=0;
for($sum=0; $sum<12; $sum++){
    $Sumatotal+=$sumames[$sum];
    echo '<td>' . $sumames[$sum].'</td>';
}
echo '<td>' .$Sumatotal.'</td>';
  

the total sum value is 407

    
asked by carlos becerra 11.10.2018 в 23:08
source

1 answer

1

You can do it this way:

file1.php

$Sumatotal=0;


                       for($sum=0; $sum<12; $sum++){
                             $Sumatotal+=$sumames[$sum];
                           echo '<td>' . $sumames[$sum].'</td>';

                       }
                        echo '<td>' .$Sumatotal.'</td>';

file2.php

If you try, for example, to print the value of the variable $Sumatotal in the file2.php it should look like this

<?php

require 'archivo1.php';

With this order it should be enough for the content of the $Sumavariable to be displayed because in the file1.php you are already printing it with the instruction echo

USE OF REQUIRE

  

REQUIRE Allows me in this case to require the content of another   file in a new one, that is to say when placing this instruction in the   file2.php I am indicating that it requires the content of   file1.php so that the code is available in this way

    
answered by 11.10.2018 / 23:12
source