Basic Built in Functions in PHP with Code Example

Basic Built in Functions in PHP

PHP have many built-in functions that you can use this function and perform some basic task, for example, date(), time(), array() and many more.

More than 1000s built-in functions are defined in the PHP.

Some PHP Pre-defined Build in Functions

date() time() strlen() str_replace()
phpinfo() php_uname() extension_loaded() Phpversion()
ini_set() ini_get() print() copy()

Example 1 – PHP Basic Built in Functions with Example

<!DOCTYPE html>
<html>
  <head>
   
  </head>
  
  <body>
	<?php
		echo "Today date is " . date("d/m/y");
		echo "<br />";
		echo "Today time is " . date("h:i:s");
	?>
  </body>
</html>

In the above code, we uses pre-defined “date” to show date and time.

Basic Built in Functions in PHP with Code Example
Fig.1 – PHP Basic Functions Or date and time Function.

Caution:If you use time function to show time than the output shown in seconds and known as “Epoch Time”.

date()

This function return date and time in the format provided to the functions. Where the formates of date are d/m/y or d-m-y.

time()

This function return time in the second format. The time is also shown by the date() function where the formate is h:i:s a or h:i:s A. Where is represent to minute.

strlen()

This function return the length of a string which was provided to the functions.

str_replace()

This function replaces a text to another text.

phpinfo()

This function returns the information about the configuration of PHP.

php_uname()

This function returns the information about the operating system where PHP is running on.

extension_loaded()

This function returns the information about a specific extension is loaded or not.

phpversion()

This function returns the information about which version of PHP is running.

ini_set()

This function is used to set the parameter or configuration option of a file.

ini_get()

This function is used to get the value of a parameter or configuration option of a file.

You can leave a response, or trackback from your own site.

3 Responses to “Basic Built in Functions in PHP with Code Example”

  1. I’m truly enjoying the design and layout of your site. It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a designer to create your theme? Great work!

  2. Hi! I could have sworn I’ve been to this site before but after reading through some of the post I realized it’s new to me. Anyways, I’m definitely delighted I found it and I’ll be bookmarking and checking back frequently!

  3. I agree with your points, good post.

Leave a Reply to the article


Learn PHP

Learning & Certifications
Follow Us
Facebook Icon   Linked In Icon   Twitter Icon  
Validation and Recognition

Valid CSS! Valid HTML5!