Hey there! any question in your mind? Ask It Now!.

Popular Categories





php: set global variable inside function

+1 vote
154 views
asked in Programming by anonymous
edited
I want to define a globel variable inside THE function in php which can be access from other files also.
Please explain with syntax.

1 Answer

0 votes
answered by Himanshu Expert (5,940 points)
You just have to initialize globally and add global keyword with that variable in the scope of function where you want to use it.

Like :

$url_checked_list = array();

function test_fun() {
global $url_checked_list;

//Some action like

$url_checked_list[]= "ABCD";



}


Here we are setting $url_checked_list array globally inside the function.

Related Questions

+1 vote
1 answer 201 views
+1 vote
1 answer 75 views
+4 votes
5 answers 713 views
0 votes
1 answer 9,829 views
+2 votes
3 answers 280 views
asked in Programming by jatin Expert (3,823 points)
+1 vote
2 answers 5,057 views
+2 votes
1 answer 141 views
+1 vote
2 answers 75 views

Not a Member yet?

Ask to Folks Login

My Account
624 Folks are online
61 members and 563 guest online
Your feedback is highly appreciated