I have the following line in a php file:
$labels['study'] = 'Study';
Then, I include that file in my index page to print the value. It gets the value but instead of printing “Study”, it prints ” Study” (with a blank at the beginnig).
I’ve tried aplying trim() to the returned value and in other places but it has no effect.
The way I’m returning the value is:
<?=get_label('study')?>
There is always a blank (or other blank characters) at the beginning.
I’m wondering why this happens. Any idea?
The get_label function is this:
function get_label($texto){
require("lang/".$_SESSION['lang'].".php");
$traduccion = trim($labels[$texto]);
if($traduccion == '')
return '['.$texto.']';
else
return $traduccion;
And the code above and below where I call the function:
<div>
<h2><?=get_label('Estudio')?></h2>
<?=get_text('estudio');?></div>
</div>
I’ve tried with all of it in the same line (from to ) and it neither works.
You probably have a space in the HTML code before the
<?=tag, not in the PHP variable.If that’s not a space, it could be a new line as well (in the HTML).