Skip to main content
added 28 characters in body
Source Link
Rarst
  • 99.9k
  • 10
  • 161
  • 298

Sorry, this is a noob question. But, I want to follow the best practices.

I read that functions and global variables should be prefixed in plugins.

So, for example, myfunction() myfunction(), should be lax_myplugin_myfunction()lax_myplugin_myfunction(). And a variable, such as $myvar$myvar, should be $lax_myplugin_myvar$lax_myplugin_myvar.

Do I need to prefix a variable if it's in a function? For example,

lax_myplugin_myfunction() {

$count = 50;

return $count;

}

lax_myplugin_myfunction() {

$count = 50;

return $count;

}

Should I prefix $count$count and make it $lax_myplugin_count$lax_myplugin_count? Or I don't have to bother with it as it's in a function. What's the best practice?

Thank you.

-Laxmidi

Sorry, this is a noob question. But, I want to follow the best practices.

I read that functions and global variables should be prefixed in plugins.

So, for example, myfunction(), should be lax_myplugin_myfunction(). And a variable, such as $myvar, should be $lax_myplugin_myvar.

Do I need to prefix a variable if it's in a function? For example,

lax_myplugin_myfunction() {

$count = 50;

return $count;

}

Should I prefix $count and make it $lax_myplugin_count? Or I don't have to bother with it as it's in a function. What's the best practice?

Thank you.

-Laxmidi

Sorry, this is a noob question. But, I want to follow the best practices.

I read that functions and global variables should be prefixed in plugins.

So, for example, myfunction(), should be lax_myplugin_myfunction(). And a variable, such as $myvar, should be $lax_myplugin_myvar.

Do I need to prefix a variable if it's in a function? For example,

lax_myplugin_myfunction() {

$count = 50;

return $count;

}

Should I prefix $count and make it $lax_myplugin_count? Or I don't have to bother with it as it's in a function. What's the best practice?

Thank you.

Source Link
Laxmidi
  • 971
  • 4
  • 19
  • 37

Do I Need to Prefix Variables Inside Functions?

Sorry, this is a noob question. But, I want to follow the best practices.

I read that functions and global variables should be prefixed in plugins.

So, for example, myfunction(), should be lax_myplugin_myfunction(). And a variable, such as $myvar, should be $lax_myplugin_myvar.

Do I need to prefix a variable if it's in a function? For example,

lax_myplugin_myfunction() {

$count = 50;

return $count;

}

Should I prefix $count and make it $lax_myplugin_count? Or I don't have to bother with it as it's in a function. What's the best practice?

Thank you.

-Laxmidi