Jump to content

Recommended Posts

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

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/136723-please-help/
Share on other sites

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
?>

Link to comment
https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714001
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714002
Share on other sites

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714007
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/136723-please-help/#findComment-714041
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.