I am trying to get php to grab data from a language file and place it on a page. Here is my code: <?php include_once("inc/language.php"); ?> PHP: Hello, my name is <?php echo $lang['name']?> PHP: Any help would be greatly appreciated. Thanks in advance.
On the second line: Hello, my name is <?php echo $lang['name']; ?> Code (markup): Notice that you forget to write the ; before ?>
although it's good practice, this doesnt matter at the moment, i think the suspect here is the language file
You need to take care of the structure of folders/files , here is how it can be done public_html/ //main site folder public_html/index.php //a main file public_html/inc/language.php //the language file Code (markup): language.php <?php $lang = array(); $lang['name']="Name"; $lang['key']="Value"; ..... PHP: index.php <?php include_once("inc/language.php"); //test to see if array is present see how many pairs you have echo count($lang); ?> Hello, my name is <?php echo $lang['name']; ?> PHP: