Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php set global variables from function

<?php 
function setGlobalVariable() {
    $GLOBALS['variable_name'] = "Some Value";
}
setGlobalVariable();
echo $variable_name;
// Outputs: Some Value
Comment

php global variable function

<?php
  $myVariable = "a";
  function changeVar($newVar) {
    global $myVariable
    $myVariable = "b";
  }
  echo $myVariable; // Should echo b
?>
Comment

how make a variable global php

$a = 1;
$b = 2;
function Sum(){
    global $a, $b; // allows access to vars outside of function
    $b = $a + $b;
} 

Sum();
echo $b; // output is 3
Comment

How to not use directly global variables in PHP


<?php
$search_html = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_SPECIAL_CHARS);
$search_url = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_ENCODED);
echo "Vous avez recherché $search_html.
";
echo "<a href='?search=$search_url'>Nouvelle recherche.</a>";
?>

Comment

PREVIOUS NEXT
Code Example
Php :: browser detection php 
Php :: Array Contant PHP 
Php :: php echo 
Php :: how validate data if is exist must not be empty in laravel 
Php :: how to generate random string in laravel 
Php :: get array key php 
Php :: strpos in php 
Php :: disable cors policy symfony 
Php :: aws s3 laravel package 
Php :: get_transient wordpress 
Php :: update pdo mysql php 
Php :: woocommerce product object 
Php :: replace accent php 
Php :: check if session is set 
Php :: how to publish stubs in laravel 
Php :: save array in mysql php 
Php :: laravel log to console 
Php :: php read csv file into array 
Php :: get post url from post id wordpress 
Php :: laravel api form request validation 404 
Php :: root directory in php 
Php :: json whereIn laravel 
Php :: twig filter line break 
Php :: pass variable to another page in js 
Php :: datetime php 
Php :: upgrade php linux 
Php :: PHP time limit (max_execution_time): 
Php :: laravel random value from array 
Php :: Deleting an element from an array in PHP 
Php :: php clone 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =