angenommen ich hab in vars.php den wert $blabla = 0; und ich möchte von index.php aus diesen wert auf 1 stellen, sprich: $blabla = 1;
wie mach ich das am simpelsten?
wie mach ich das am simpelsten?
include 'vars.php';
$blabla = 1;
<?php
include("vars.php");
echo "Useronline: " . $user_online . "<br />";
echo "Username: " . $user_name . "<br />";
echo "Lieblingszahl: " . $user_favourite_number . "<br />";
echo "<br /><br />";
#$handle = fopen("vars.php","r+");
$array = file("vars.php");
$file = implode("\n", $array);
preg_replace("\$user_online = 0","\$user_online = 1",$file);
echo "<br /><br />";
include("vars.php");
echo "Useronline: " . $user_online . "<br />";
echo "Username: " . $user_name . "<br />";
echo "Lieblingszahl: " . $user_favourite_number . "<br />";
?>
<?php
$user_online = 0;
$user_name = "max";
$user_favourite_number = 2;
?>
Kommentar