How to pass varivlle from a PHP file to another PHP file [duplicate]

0

I have a script that generates a pdf file. The file name is defined in MergePdf.class.php

But I wanted it to be defined in the source file (variable $ filename), where it calls this php, which is below:

//destination path for the User PDF file:
$nomearquivo = 'teste';
$pdfUserfile = JPATH_SITE.'/pdf/pdf-padrao1.pdf';
copy($pdfUser,$pdfUserfile);
require_once("/home/site/public_html/scripts/pdf/MergePdf.class.php");
MergePdf::merge(
    Array(
        $pdfUserfile,
         $arquivoiptu
    ),
    MergePdf::DESTINATION__DISK_INLINE
);

Then I would need to pass this $ filename to MergePdf.class.php, but I do not know how to do it.

    
asked by anonymous 11.10.2018 / 14:47

2 answers

0

Use the include in the file you want to use the variable.

example: file.php

echo $ filename;

// the result must be 'test' which is defined in the file 'MergePdf.class.php'

    
11.10.2018 / 14:57
0

To use a variable defined in another file in the current file, you should use the include statement.

Example of using the declaration

file1.php

<?php 
  $primeiroNumero = 1;
?>

file2.php

<?php 
  include 'arquivo1.php';
  $segundoNumero = 2;

  $soma = $primeiroNumero + $segundoNumero;
  echo $soma; //Mostrará a soma 1+2 = 3
?>
    
11.10.2018 / 18:47