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...
The thing to remember about settype() is that it returns boolean true or false and takes a variable as the first argument. For example: $var = 'hello world!'; $arr = ['hello world!']; settype($var, 'array'); settype($arr, 'array'); echo ($var === $arr); // output: ...
Tip: It is possible to reuse the same name for a variable in different functions, since local variables are only recognized by the function in which they are declared.The global KeywordThere may be a situation when you need to import a variable from the main program into a function, or ...
echo gettype($x + $y); ?> Output Conclusion In thisPHP Tutorial, we learned how to get the type of a variable, a value, or an expression, usinggettype()function, with examples.
#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...
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...
You can use the PHP is_null() function to check whether a variable is null or not.Let's check out an example to understand how this function works:ExampleTry this code » <?php $var = NULL; // Testing the variable if(is_null($var)){ echo 'This line is printed, because the $...
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...
In PHP, you can call object methods with the help ofcall_user_func(). Here the argument is an array that includes the object variable and the method string name to be called. Let’s check out an example: <?php// PHP program to demonstrate the working// of a object method callback/...