Pro.Luv Posted December 12, 2008 Share Posted December 12, 2008 Hi guys, I'm using define to change the page language like: define('home','Heim',true); the problem I'm having is if I echo strings with inverted comma's they don't change like: echo "Home"; The home doesn't change unless I echo it without the inverted comma's echo home; This is making it difficult cause I can't print out reserved words like " and, if " like: echo and; echo if; I get error's how can I echo those words ? I really need help with this and I have chinese as a language but when I create the php document like: define("search", "搜索",true); the chinese words turn into ?? question marks is it my editor ? I really need help with this... Thanks Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/ Share on other sites More sharing options...
Prismatic Posted December 12, 2008 Share Posted December 12, 2008 The words change into ?? because your application doesn't support the language you've tried to display. Also, echo must be used with quotes, single or double. <?php echo Hello World!; //Parse error echo "Hello World!"; //Good echo 'Hello World!'; //Good ?> Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714001 Share on other sites More sharing options...
ted_chou12 Posted December 12, 2008 Share Posted December 12, 2008 in php variables are usually defined like: $home = "home";//u have to surround texts by quotation marks echo $home; //gives u home. echo "if"; //gives u if echo "and"; //gives u and but the chinese character has nothing to do with this, is the charset problem Ted Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714002 Share on other sites More sharing options...
Pro.Luv Posted December 12, 2008 Author Share Posted December 12, 2008 I tried using: echo "and"; echo "if"; but when the in inverted comma's the word does not change to the language selected. I checked the manual: define("CONSTANT", "Hello world."); echo CONSTANT; // outputs "Hello world." echo Constant; // outputs "Constant" and issues a notice. it shows that echo is used without the inverted comma's Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714007 Share on other sites More sharing options...
ted_chou12 Posted December 12, 2008 Share Posted December 12, 2008 im not familiar with the language u r using but I guess u should try this: $constant = "Hello world."; echo $constant; //gives u Hello world. Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714012 Share on other sites More sharing options...
Pro.Luv Posted December 12, 2008 Author Share Posted December 12, 2008 It's PHP... When you use define and you want to change a word say for example: welcome.. it would be define("welcome","Welcome User !"); echo welcome; // gives you Welcome User ! echo "welcome"; //gives you welcome, no change Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714021 Share on other sites More sharing options...
ted_chou12 Posted December 12, 2008 Share Posted December 12, 2008 I am not sure exactly what u r trying to achieve here ??? The php I am familiar is to define a variable as $var = "string"; Ted Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714026 Share on other sites More sharing options...
Pro.Luv Posted December 12, 2008 Author Share Posted December 12, 2008 I'm sorry if I'm confusing you ted_chou12 really am great full for your help.. I'm trying to Define a named constant.. Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714033 Share on other sites More sharing options...
ngreenwood6 Posted December 12, 2008 Share Posted December 12, 2008 in order to define a constant you will use this: define("constant name", "constant value"); echo constant("constant name"); Note that it is case sensitive to the constant name. I think that is what you are looking for. Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714038 Share on other sites More sharing options...
ngreenwood6 Posted December 12, 2008 Share Posted December 12, 2008 You can refer to this page for help. http://www.w3schools.com/PHP/func_misc_define.asp Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714039 Share on other sites More sharing options...
premiso Posted December 12, 2008 Share Posted December 12, 2008 Ok ted_chou read up on constants in PHP please. As far as you code Pro.Luv, maybe this will help. echo "Home"; // echos "Home" echo home; // echos home, if there are no constants defined. define("home", "Test Home!", true); echo home; // echos "Test Home!" echo "home"; // this echos "home" since it is used in the context of quotes. So with constants you cannot use the " " around them to display them. You were just thinking that putting a defined variable inside of an echo with quotes it should work, it does not. constants Read up on constants in PHP. As for your chinesse error I would look up your editor and see if they have a language deal. You will have to change the page char type in order to display that. Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714041 Share on other sites More sharing options...
ted_chou12 Posted December 12, 2008 Share Posted December 12, 2008 r those new functions ??? how come i havent encounter them before Ted Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714043 Share on other sites More sharing options...
premiso Posted December 12, 2008 Share Posted December 12, 2008 r those new functions ??? how come i havent encounter them before Ted Nope, been around since the start. The reason you never encountered, is either you did not know about PHP and constants, or you never had a need for them. Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714045 Share on other sites More sharing options...
Pro.Luv Posted December 12, 2008 Author Share Posted December 12, 2008 thanks premiso will read up on it, thanks for all the help!! Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714048 Share on other sites More sharing options...
ted_chou12 Posted December 12, 2008 Share Posted December 12, 2008 or you never had a need for them. probably Quote Link to comment https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714049 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.