Answer the question
In order to leave comments, you need to log in
How to change the value of a variable in PHP from another file?
I’ll immediately say a question from a beginner)) don’t judge strictly)))
There is a test.php file in it there is a variable:
<?$name = 'Ivan';?>
There is also another setting.php file
Question: What kind of php code should I write in the file setting.php which will allow you to change the value of the $name variable in another test.php file?
Thank you very much in advance!!!
Answer the question
In order to leave comments, you need to log in
Are you trying to make a slider? If yes, then look at how it is implemented by others. In general, write a function that reacts to a click and transfers the id of the picture to the server. For example, you clicked on next, and next you have a picture with id=2, passed this value to the server, it found the corresponding picture and gave it back.
www.php.su/articles/?cat=fs&page=005
Read. Without the code of your files, I can not advise more.
Yes, that's right, only it somehow needs to be specified from another file. I can just change the value of the variable myself)))
settings.php file
<?php
$config = [
'name' => 'vasya',
'test_conf' => 1,
];
<?php
require_once "settings.php"; // подключим массив с настройками.
foreach($config as $key => $value) { // преобразуем массив в переменные
$$key=$value;
}
echo $name; // vasya
echo $test_conf; // 1
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question