I have a set of variables that are set outside the target php include file, how would i set them in the target php include file. Example:
<?php
$fname = "david";
?>
Now how would I set $fname in another php file?
In your other PHP file you would do:
<?php
$fname = "david";
?>
This answers your question directly, but I would hazard a guess that you actually want to have access to variables that are set in a file that is included into your current file or something along those lines.
So
File1.php:
<?php
$fname = "david";
?>
File2.php
<?php
require_once 'File1.php';
echo $fname;
Would result in david being printed to screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With