I'm trying to drag global variable $ nsfw but it does not show anything. If I resonate it inside the function, then it works. But outside, it fails even when it is defined in the global form. Please help me here.
& lt ;? Php if (! Function_exists ('do_example_work')) {function do_example_work () {global $ nsfw; ("Include / dbconnect.php"); // Create Connection $ conn = new mysqli ($ DBHOST, $ DBUSER, $ DBPASS, $ DBNAME); // Check connection if ($ conn- & gt; connect_error) {dead ("Connection failed:". $ Conn-> connect_error); } $ Sql = "Select the field name from the table where '$' anything" "; $ result = $ conn- & gt; query ($ sql); ($ Row [" fieldname "] == 1) (If $ $ -> $ line = $ result-> output data of each row ($ result-> num_rows & gt; 0) / something $ nsfw = 25; out Go ();} and {resonate "joy";}}} {echo "0 result"}} echo $ nsfw;};? & Gt;
< Div class = "post-text" itemprop = "text">
There are logic for globals and you can search the pile and the Internet and read about it:
- G Lobels are bad in many ways, and should be avoided where possible
- Globals are not bad and can be fine if you know what you are doing then safe to use /
manual:
function.
OUT
If you have data for a function Use statement
function do_example_work () {// some stuff here, if you want to get outside $ Nsfw = 25; Return $ NSFW; // where required, conditional statement or the completion of the function} // "echo" resonates 25 i_example_work ();
IN
FYI:
To get data out in , simply pass Make the data passed from your function as an argument from outside:
function do_example_work ($ nsfw) {/ ** var "$ nsfw" through function call * Gone data can be used as required - $ nsfw == Check something * or this database can be login details (urgh) * / echo $ nsfw. "- and the word from the function"; } // Will "pass in logic" and "word from function" will be "do_example_work" (in the argument "pass");
No comments:
Post a Comment