Sitemap
hrishi dhisale

hrishi dhisale

25 + PHP Function List

2 min readMay 11, 2020
Press enter or click to view image in full size

This is a list of 25 interesting PHP functions that are useful in different situations. This is a list of 25 interesting PHP functions that are useful in different situations.

Ceil () :

Round number up to the nearest integer,

  1. echo (ceil(0.60)); ====> 1.
  2. echo (ceil(0.45)); ====> 1.
  3. echo (ceil(-1.3)); ====> -1.
  4. echo (ceil(-4.3)); ====> -4.

Rounded value getting only nearest integer value print.

Count () :

The count function returns the number of elements in an array.

<?php

$color= array(“red”,”black”,”yellow”);

echo Count ($color);

?>

====> 3

die () :

  • die (message );

<?php

$connection = mysqli_connect(“localhost”,”root “,””,”db_name”);

or die (“netword unavilable”);

?>

empty () ; :

<?php

$a =10 ;

if(empty($a))

{

echo “variable ‘a’ is empty”;

Get hrishi dhisale’s stories in your inbox

Join Medium for free to get updates from this writer.

}

if(isset($a))

{

echo “variable ‘a’ is set “;

}

?>

define () and Constant () :

define (name , value ,case insesitive);

  • A constants value connot be changed after it is set .
  • Constant names do not need a leading dollar sign ($).
  • Constants can be arrested regardless of scope.
  • Constant values can only be string and number.

<?php

define (“GREETING” ,”hello you ! how are you” );

echo constant(“GREETING”);

?>

Output: hello you ! how are you

defined (name); :

<?php

define (“GREETING”,”hello you! how are you “);

echo defined (“GREETING”);

?>

Output: hello you ! how are you.

file_get_contents () :

Read a file into a string.

file_get_contents (file name) ;

<?php

$content=file_get_contents(‘file_name.txt ‘);

echo $content;

?>

--

--