During PHP class initialization, can't variable parameters be used? how can this problem be solved?

Source: Internet
Author: User
During PHP class initialization, can't variable parameters be used? how can this problem be solved? At Comrade Wan, I encountered a problem.

I just thought it would be enough to use a function. it would be okay to use double quotation marks directly, but it would not respond if I changed it to a variable. Amount

$ Entxt = $ _ GET ["entxt"];
Echo $ entxt;
$ X = new fanyi ($ entxt, 1 );
Echo $ x-> go ();
Class fanyi
{


Reply to discussion (solution)

There is no problem with double quotation marks directly, and it will not respond if it is changed to a variable.
Not understood

There is no problem with double quotation marks directly, and it will not respond if it is changed to a variable.
Not understood
This can be:

 go();class fanyi{var $cilentID;var $clientSecret;var $authUrl;var $scopeUrl;var $grantType;var $inputstring;var $toLanguage;var $fromLanguage;function __construct($inputstring,$biao='0'){


This is not acceptable.
$ Entxt = $ _ GET ["entxt"];
Echo $ entxt;
$ X = new fanyi ("hello baby", 1 );
Echo $ x-> go ();
Class fanyi
{
Var $ cilentID;
Var $ clientSecret;
Var $ authUrl;
Var $ scopeUrl;
Var $ grantType;
Var $ inputstring;
Var $ toLanguage;
Var $ fromLanguage;
Function _ construct ($ inputstring, $ biao = '0 ')
{

There is no problem with double quotation marks directly, and it will not respond if it is changed to a variable.
Not understood
The opposite is true. the above is not acceptable. The following is acceptable.

New fanyi ($ entxt;, 1 );
If a semicolon is added, the syntax error cannot be parsed, and you have blocked the error prompt, so this problem cannot be found.

A semicolon is added to the same building.

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.