Skip to content
Advertisement

PHP Function to return string

I am fairly new to PHP. I have a function which checks the cost of price. I want to return the variable from this function to be used globally:

JavaScript

Advertisement

Answer

You should simply store the return value in a variable:

JavaScript

The $deliveryPrice variable above is a different variable than the $deliveryPrice inside the function. The latter is not visible outside the function because of variable scope.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement