It will return the output respect to variable declaration and value that given as input by programmer. Advertisement devloprr.com - A Social Media Platform Created for Developers Join Now ➔ <?php $str="Hello"; $n=23; $fn=3.45; echo 'String variable value : '.$str; echo '<br> Int...
#php 7.x<?php$crypto='Bitcoin';functionbody(){global$crypto;echo$crypto." is a top cryptocurrency.";}body();?> Output: Bitcoin is a top cryptocurrency. We can use the$GLOBALSsuper global variable to reference the global scope variables. The$GLOBALSvariable is an associative array that con...
Tip:An argument is a value that you pass to a function, and a parameter is the variable within the function that receives the argument. However, in common usage these terms are interchangeable i.e. an argument is a parameter is an argument. ...
This method takes a string in any case as an argument and returns uppercase string. Syntax strtoupper(string) PHP code to convert string into uppercase <?php// Declaring a variable and assigning// string in it$str="hello friends";// Converting to uppercase, and printing itechostrtoupper($...
PHP code to demonstrate example of break in a foreach loop <?php// array defination$names=array("joe","liz","dan","kelly","joy","max");// foreach loopforeach($namesas$name){// display of the loopecho$name."<br>";// stop when name is equal to danif($name=="dan"){break...
Useprint_r()Function to Echo or Print an Array in PHP The built-in functionprint_r()is used to print the value stored in a variable in PHP. We can also use it to print an array. It prints all the values of the array along with their index number. The correct syntax to use this...
When the server comes across the PHPSESSID cookie, it will try to initialize a session with that session id. It does so by loading the session file which was created earlier, during session initialization. It will then initialize the super-global array variable $_SESSION with the data stored...
Program to print the value of local variable outside the function Code: <!DOCTYPE html> <html> <body> <?php //php function function myLocal() { // local variable 'name' having the local scope $name = 'Rajesh'; echo "<p>Hello the value of local variable inside the function is : ...
A compile-time fatal error occurs when the developer uses an undefined function, class, or non-existent variable or data. A runtime fatal error is similar to a compile-time fatal error but happens during the program execution. Here’s an example of a PHP fatal error: ...
<?php $array = array( 'Name' => 'Leo', 'Age' => 25, ); echo $json = json_encode($array); ?> #output: {"Name":"Leo","Age":25} Converting array to string using serialize() The serialize() function is used a variable (in our case, an array) into a storable state. The ...