what is built in function in php ? and whts the difference of it with user defined functions? i think isset, unset, gettype,settype, strlen, strpos etc are built in function and when we write a function like this > function name{} that is user defined ? im little bit confused about this, please help me boss.

Recommended Answers

All 3 Replies

Yep, things like isset is an inbuilt function that can be called at any time. A user defined function is something that MUST be set manually like this:

<?php

    function MyName()
    {
        echo 'My Name is AHarrisGsy';
    }

?>

You would then call it like this:

MyName();

Which should (providing it is done correctly), echo the words: "My Name is AHarrisGsy"

Good luck, I hope this helps and happy coding!

Member Avatar for diafol

As a rule functions will return a value. It is up to the calling code what to do with that value.

e.g.

function welcome($name){
    return "my name is $name";
}

echo welcome('diafol'); //prints: my name is diafol

$sentence = welcome('diawl');
echo "I live in Hell and $sentence"; //prints: I live in Hell and my name is diawl
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.