premium4ya Posted October 22, 2013 Share Posted October 22, 2013 Hi all I am a beginner on PHP. As I was studying some examples, I faced the leading underscore before functions names and the slash before variable names and I can't figure out why they used them. Can any one explaing the use of them. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 22, 2013 Share Posted October 22, 2013 (edited) function names can be defined with letters, numbers and underscores. The underscore has no special meaning. How ever with OOP, method names that begin with an underscore are treated a private functions, it was a coding convention back in PHP4. If a variable has a slash in front of it, it is to prevent the variable form parsing in double quotes strings. For example $var = 'hello'; echo "The value of \$var is: $var"; // outputs: The value of $var is: hello Edited October 22, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
premium4ya Posted October 22, 2013 Author Share Posted October 22, 2013 Thanks for your reply Quote Link to comment 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.