Error in printing data echo - PHP

2

I am printing a Urls with several data in a single echo the url to print is: http://localhost/prueba/profile.php and the values of the variables are: $ url = http:// $ host = localhost APP-RAIZ = prueba

Try the following form but print an error:

echo '<a href="'.$url $host APP_RAIZ.' profile.php">Iniciar Sesión</a>';
  

Parse error: syntax error, unexpected '$ host' (T_VARIABLE), expecting ',' or ';' in C: \ xampp \ htdocs \ test \ header.php on line 53

Try the following way but it also prints an error:

echo "<a href="'.$url $host APP_RAIZ.' profile.php">Iniciar Sesión</a>";
  

Parse error: syntax error, unexpected ''. $ url $ host; APP_RAIZ ;. '' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in C: \ xampp \ htdocs \ test \ header.php on line 54

Of the following form also but without result.

echo '<a href=" '.$url.' '.$host.' '.APP_RAIZ;.' login.php">Iniciar Sesión</a>';

I have made another type of printing of several data in a single echo without any error, I do not see where I am doing wrong in printing the url

echo'<img src="img/upload/'.$pro['image'].'" alt="'.$pro['profile'].'" />';
    
asked by Alex 29.09.2017 в 23:30
source

1 answer

2

The error that is shown are due to syntax errors (syntax) in the last attempt you were a thousandth to achieve it but you were wrong in one detail.

In attempt 1

echo '<a href="'.$url $host APP_RAIZ.' profile.php">Iniciar Sesión</a>';
  

I just added the following '..' in each variable that contained data

In the last attempt

echo '<a href=" '.$url.' '.$host.' '.APP_RAIZ;.' login.php">Iniciar Sesión</a>';
  

Already you had it for a detail you printed the error, you should have removed the following ; a APP_RAIZ

The solution

echo '<a href="'.$url.''.$host.''.APP_RAIZ.'profile.php">Profile</a>'; 
  

Some very useful references

answered by 30.09.2017 / 01:12
source