Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP echo $_SERVER['PHP_SELF'] with added variable?

Tags:

php

Just want to do $_SERVER['PHP_SELF'] as a link with ?logout=1 appended to it.

<a href="<?php echo ''$_SERVER['PHP_SELF']'.logout=1' ?>" id="add"><input type="button" value="LOGOUT" /></a>

gives

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in F:\export\srv\www\vhosts\main\htdocs\php\assign3\m_a2_functions.php on line 90
like image 796
eveo Avatar asked Apr 10 '12 02:04

eveo


3 Answers

Change:

<?php echo ''$_SERVER['PHP_SELF']'.logout=1' ?>

To:

<?php echo $_SERVER['PHP_SELF'], '?logout=1' ?>
like image 190
Paul Avatar answered Sep 18 '22 18:09

Paul


<a href="<?php echo $_SERVER['PHP_SELF'] . '?logout=1' ?>" id="add">
like image 38
JT Smith Avatar answered Sep 21 '22 18:09

JT Smith


have you tried:

<?php echo($_SERVER['PHP_SELF'] . "?logout=1") ?>
like image 30
Ali Hamze Avatar answered Sep 17 '22 18:09

Ali Hamze