In the previous tutorials, we have discussed about string functions and array() function. String function and array () function are also built-in functions that are used for different functionalities. The functions which are already readymade are called built-in functions. The developer has already created a lot of functions that we can use to perform different tasks. We also call the built-in function as Readymade functions. Built-in functions are different from the user-defined function . The user define function has to create the user himself, but the built-in function only requires you to use it. The functionality of all readymade functions is already made. While the user defines their own functionality in user define function.
Built-in functions are those functions that are already readymade. These functions are used for a specific purpose. Each built-in function has different functionalities.These built-in functions are used only on the basis of their functionality.Many built-in functions are available in PHP
Echo() function is a PHP built-in function that is used to display the statements (Print the output).
Echo() function is used for more than one string .Echo() function can take a comma-delimited list of arguments to output. Echo() function doesn’t return any value.
echo "statements"; or echo 'statements';
The follwing example of echo built-in function
<?php echo "Learn PHP built functions"; ?>
In above example you can see one statement is written under the echo function .When code is executed the output will generate – Learn PHP built functions.
Here ,we used the echo function only to display the statement. The functionalities of built-in functions are readymade in the PHP library. That's why we can call the readymade functionality using echo() function only to display the statements.
Print() function also used to display the statement (output ) .Print() function is used to only one string.
We cannot use multiple string like echo() function .The print function is also a built-in function in PHP.Print return a value.We can use print() function with parenthesis or without parenthesis .
.It's slower than echo.
Print always return 1.
<?php $webname="TechnoSmarter"; print $webname; //or print ($webname); ?>
In the above example, we print the statement with parentheses or without parenthesis. That is a major advantage of the print() function in PHP. The disadvantage of the print function, It is slower than the echo() function.
Before you start learn PHP, you have learnt C language (computer programming language ) . In c language we have used Printf function for print the statement .
In other programming languages (C, C++, Java, Python, Bash...) have similar format of Printf() function and way to treat strings.
So its good for you to know it, and for those who already know, it's easier.
The printf() function is also a built_in function. It is a very easy and you already know about the Printf () function.
printf() is a part of C's printf() function, However, most people who start with PHP find it rather confusing but it’s very simple to use if you have learnt c programming .
<?php $str="This is a simple example of printf"; $res1=strlen($str); $res2=str_word_count($str); printf("Your string lenght is %d. You string words count: %d",$res1,$res2); ?>
The conclusion comes out from the above examples that only the functionality of the built-in function should be known to you. To understand the functionality of built-in functions, you need to do practice daily. Only then will you easily understand all the built-in functions. The developer has created a lot of built-in functions in PHP which can be used for different tasks.