UrbanPro

Learn PHP from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How can I use the same variable declared for different functions in PHP?

Asked by Last Modified  

3 Answers

Learn PHP

Follow 2
Answer

Please enter your answer

#2 Using $GLOBALS instead of global The $GLOBALS array is an associative array with the name of the global variable being the key and the contents of that variable being the value of the array element. Notice how $GLOBALS exists in any scope, this is because $GLOBALS is a superglobal. Here's an...
read more
#2 Using $GLOBALS instead of global The $GLOBALS array is an associative array with the name of the global variable being the key and the contents of that variable being the value of the array element. Notice how $GLOBALS exists in any scope, this is because $GLOBALS is a superglobal. Here's an example demonstrating the power of superglobals: read less
Comments

Hello Vishal, PHP supports the concept of variable functions. This means that if a variable name has parentheses appended to it, PHP will look for a function with the same name as whatever the variable evaluates to, and will attempt to execute it. Among other things, this can be used to implement callbacks,...
read more
Hello Vishal, PHP supports the concept of variable functions. This means that if a variable name has parentheses appended to it, PHP will look for a function with the same name as whatever the variable evaluates to, and will attempt to execute it. Among other things, this can be used to implement callbacks, function tables, and so forth. Variable functions won't work with language constructs such as echo, print, unset(), isset(), empty(), include, require and the like. Utilize wrapper functions to make use of any of these constructs as variable functions. read less
Comments

Realtime Website Development

/* ***** If you wanna understand usage of global variables ***** */ function test1() { global $var; /* declare as global variable */ $var = "value"; } function test2() { global $var; /* declare as global variable */ echo $var; /* used here */ } /* ***** If you wanna understand...
read more
/* ***** If you wanna understand usage of global variables ***** */ function test1() { global $var; /* declare as global variable */ $var = "value"; } function test2() { global $var; /* declare as global variable */ echo $var; /* used here */ } /* ***** If you wanna understand usage of static variables ***** */ class testClass { private static $a = 1; public static function a() { self::$a = 2; } public static function b() { echo self::$a; } } You can then call the functions: testClass::a(); testClass::b(); read less
Comments

View 1 more Answers

Related Questions

PHP (LAMP) for entrepreneurs, is there any full time, fast track classes on PHP(LAMP) for entrepreneurs, who want are want to do some tech part in their startups
Yes, You have option. You can Join. Xpert Infotech, New Delhi. Before going through Silverlight live project training candidate should have knowledge of given concepts listed below: Knowledge of HTML...
Saee
0 0
6
Which is best to build web applications: PHP, Python, or Ruby? Why?
I have used almost all of the three language in my web working experience.PHP:It may be not that cool and I think it doesn't rely too much on the framework. Yes, PHP is just a language, but it is the only...
Sunil
0 0
7
What are the ideas for final year projects based on PHP?
Social Networking System, College Management System, Inventory Management System, eCommerce portal etc.
Nishit
0 0
5
Looking for Yii Framework experts who are willing to train.
A constructor is a special method of a class in object-oriented programming that initializes an object of that type. A constructor will have same name as the class, and can be used to set the values...
Pritam

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Components of Digital Marketing
Content marketing Search Engine Optimization (SEO) Paid Search (PPC) Email marketing Social Media Marketing Digital Display Marketing (Ad Ops) Web Analytics and Reporting Mobile Marketing 30...

User Authenication In PHP: Some Advanced echniques
User Authentication in CodeIgniter: Goals Security: We want our login system to be secure, we want to do everything we can to stop people’s accounts being hacked into. Tracking: We’d like...

Core PHP v/s PHP Frameworks
PHP Frameworks: Framework is a piece of software by which one can develop large enterprise, robust & secure software applications. Frameworks provide straight forward flow and strict guidelines by...

What is Array in PHP | Types of Array
An array is a special variable, which can hold more than one value at a time or you can say An array stores multiple values in one single variable. If you have a list of items (a list of car names, for...

Student Project Development: How To Go About It?
A lot of students (count me as well) in their final year of IT course are confused and overwhelmed about their Project development. Final Year IT Projects are a crucial milestone in every IT students educational...

Recommended Articles

Almost all of us, inside the pocket, bag or on the table have a mobile phone, out of which 90% of us have a smartphone. The technology is advancing rapidly. When it comes to mobile phones, people today want much more than just making phone calls and playing games on the go. People now want instant access to all their business...

Read full article >

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

Read full article >

Looking for PHP Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for PHP Classes?

The best tutors for PHP Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn PHP with the Best Tutors

The best Tutors for PHP Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more