Let's take a look at the problem-php Tutorial.

Source: Internet
Author: User
Let's take a look at what went wrong & lt ;? Phpecho $ titleImg ;? & Gt; why can't I output the following code: & lt ;? Phprequire (web. config. php); return_lang (); $ do $ _ GET [do]; $ gchr (92); $ dostr_replace ($ g, & quot ;, $ _ let's take a look at what went wrong.
Why can't I output this?

The code is as follows:

Require ('web. config. php ');
Return_lang ();
$ Do = $ _ GET ['do '];
$ G = chr (92 );
$ Do = str_replace ($ g, "", $ _ GET ['do ']);
$ Do = str_replace ("/", "", $ do );
$ Do = str_replace ("% 00", "\ 0", $ do );
$ Do = str_replace ("? "," ", $ Do );
$ Do = htmlspecialchars ($ do );
$ Do = strtolower ($ do );
If (! Isset ($ _ GET ['do ']) {jump ('extend. php? Do = webreborn ');} else {
If ($ user_auth-> haslogin (true )){
$ Rs = $ db-> Execute ("Select * from userinfo where userid =? ", Array ($ _ SESSION ['auth _ user']);
$ Auth = $ rs-> GetArray ();
$ Auth = $ auth [0];

Class char_do extends Member {

Var $ inputs = array ('chalist', 'id', 'CID', 'schoollist ');
Var $ stn_rb = false;
Var $ vip_rb = false;

Function char_do (){
Global $ do, $ db, $ auth, $ _ config;
If (! Is_file ("modules/user.". $ do. ". php") {jump ('errorpage. php ');}
Switch ($ do ){


Case 'webpd ':
Include ('Les les/user. webpd. php ');
$ TitleImg = "title_37 ";
Break;


// You can add more page here .....

}
}

Function _ char_select_empty (){
If ($ _ POST [$ this-> inputs [0]! = "-1 "){
Return true;
}
Return false;
}
Function _ school_select_empty (){
If ($ _ POST [$ this-> inputs [3]! = "-1 "){
Return true;
}
Return false;
}
Function _ update_rb_lvl_exp ($ db, $ id ){
Global $ _ config;
$ Rb_res = $ db-> Execute ('update rangame1.dbo. chainfo set '. $ _ config ['ucs_rb_col ']. '= '. $ _ config ['ucs_rb_col ']. '+ ?, ChaLevel = ?, Chaexp =? Where chanum =? ', Array ('1', '1', '0', $ id ));
If ($ rb_res ){
Return true;
}
Return false;
}
Function _ charge_gold ($ db, $ id, $ cost ){
$ Gold_res = $ db-> Execute ('update rangame1.dbo. chainfo set ChaMoney = ChaMoney -? Where chanum =? ', Array ($ cost, $ id ));
If ($ gold_res ){
Return true;
}
Return false;
}
Function resetRbStats ($ db, $ id ){
$ Char_res = $ db-> Execute ('update RanGame1.dbo. ChaInfo set ChaPower = ?, ChaStrong = ?, ChaStrength = ?, ChaSpirit = ?, ChaDex = ?, ChaStRemain =? Where chanum =? ', Array (0, 0, 0, 0, 0, $ id ));
If ($ char_res ){
Return true;
}
Return false;
}
Function _ update_rb_stats ($ db, $ cid, $ stats, $ rev = false ){
If ($ rev = true ){
$ Stn_res = $ db-> Execute ('update rangame1.dbo. chainfo set ChaStRemain = ChaStRemain +? Where chanum =? ', Array ($ stats, $ cid ));
} Else {
$ Stn_res = $ db-> Execute ('update rangame1.dbo. chainfo set ChaStRemain =? Where chanum =? ', Array ($ stats, $ cid ));
}
If ($ stn_res ){
Return true;
}
Return false;
}
Function _ char_list (){
Global $ db, $ auth;
$ Char_list = $ db-> Execute ("SELECT UserNum, ChaNum, ChaName FROM RanGame1.dbo. ChaInfo Where ChaDeleted! = 1 And UserNum =? ", Array ($ auth ['usernum']);
If ($ char_list-> EOF)
Echo' No char';
Foreach ($ char_list as $ char => $ c ){
$ Temp_c =' If (clean_variable ($ _ POST [$ this-> inputs [0]) = $ c ["chanum"]) {
$ Temp_c. = 'Selected = "selected "';
}
$ Temp_c. = 'value = "'. $ c [" chanum "].'"> ';
$ Temp_c. = $ c ["chaname"];
$ Temp_c. ='';

Echo $ temp_c;
}
}
}
$ Char_func = new char_do;
?>

Call Why cannot It be output?

------ Solution --------------------
$ TitleImg, scope
------ Solution --------------------
$ TitleImg is defined in function char_do and is not declared as a global variable.
Only global $ do, $ db, $ auth, $ _ config;

Therefore, it cannot be accessed externally.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.