jburridge Posted September 30, 2013 Share Posted September 30, 2013 I'm trying to figure out what these examples of code are called? "DB()" "connect()" I don't believe they are variables because they are not defined anywhere in another part of a script. I'm also wondering if someone knows where I can find a list of all of these so I get a better understanding of all the functions of php. Quote Link to comment https://forums.phpfreaks.com/topic/282578-what-are-these-called/ Share on other sites More sharing options...
kicken Posted September 30, 2013 Share Posted September 30, 2013 (edited) Functions. There are both built-in functions which are all documented in the php manual, and user-defined functions which would be defined in your codebase somewhere. Neither of the two examples you gave are built-in so they would be defined in your code somewhere. Edited September 30, 2013 by kicken Quote Link to comment https://forums.phpfreaks.com/topic/282578-what-are-these-called/#findComment-1451925 Share on other sites More sharing options...
Ch0cu3r Posted September 30, 2013 Share Posted September 30, 2013 Everything you need to know about PHP is in the manual. This is the first place you should go for help. The manual Quote Link to comment https://forums.phpfreaks.com/topic/282578-what-are-these-called/#findComment-1451926 Share on other sites More sharing options...
.josh Posted September 30, 2013 Share Posted September 30, 2013 They are called functions. They are usually defined as such: function DB() { // do something } // call the function DB(); They are also class methods, though the syntax is slightly different. Example: class myClass { public function DB() { // do something; } } // call it $myClass = new myClass(); $myClass->DB(); *usually* a function will accept arguments and return something. For example: function makeLink($url,$text) { if (isset($url)&&isset($text)) { return "<a href='$url'>$text</a>"; } return ''; } // provide url and text and get an html marked up link in return $link = makeLink('http://www.google.com','google!'); echo $link; // output: <a href='http://www.google.com'>google!</a> Quote Link to comment https://forums.phpfreaks.com/topic/282578-what-are-these-called/#findComment-1451929 Share on other sites More sharing options...
.josh Posted September 30, 2013 Share Posted September 30, 2013 there is no enforced rule, but functions are usually named for what they do. For example that connect() example probably has code in it to connect to a database or socket and return a resource handle for the connection. Quote Link to comment https://forums.phpfreaks.com/topic/282578-what-are-these-called/#findComment-1451931 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.