Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

How to Defines PHP functions Arguments Global Values?

In this blog, I am going to Defines PHP functions Arguments Global Values. When it comes to functions you can name a function just like a variable but it has to start with a letter. So either a character or underscore.


So these are all ok to call your functions but you can’t start a function with a number because it will see immediately it goes green because it’s not going to be recognized as a function anymore.

So is going to make sure that we’re properly formatting characters that when we’re naming the functions.

You can also within functions you don’t necessarily need to have a return. So I can also do something like this. To repeat over and over again. And that’s what functions do. It normally wouldn’t be used in this type of circumstance but this is just to illustrate what we can do with functions and how they can work if we’re repeating the same thing over and over again. Then this is where the function comes in.

So if we had a value of equals five the equals nine and if we had our function take a while just to see equals A plus B.And maybe will also increment A and will decrease B. So every time we run the function all of this is happening. So now we’re going to add in that value of C, A is B as so we’ll see what happens.

And so when we look at this we realize that it’s actually not passing in these values into the function. One way to solve this is to declare A and B global because these are outside of the function. So they’re not actually locally within the function.

And then use that variable within here just so that we can have all of our set values up here at the And if we want to make any adjustments we can always make adjustments down here at the bottom. So set them as variables and do something like that. And then this way if I want to have right out 15 times it’s a simple as making updates there and we can write it out as many times as we want.

Rajesh Kumar
Follow me