tqla Posted May 2, 2009 Share Posted May 2, 2009 I am working on a script that has lines like this: <iframe src="script.php?card_id=<?=$_GET['card_id']?><?=isset($_GET['prv'])?'&prv='.$_GET['prv']:''?>" width="638" height="848" scrolling="no" frameborder="0"></iframe> My goal is to get it out of an iFrame and just use includes but I have never seen this before: <?=isset() Is this some kind of php shorthand? What does it mean? Thanks. Link to comment https://forums.phpfreaks.com/topic/156470-solved-shorthand-php/ Share on other sites More sharing options...
the182guy Posted May 2, 2009 Share Posted May 2, 2009 <?=$some_variable?> is the same as <?php echo $some_variable; ?> In PHP you can use the short open tag, as long as it is set to be allowed in your php.ini short_open_tag 1/0 You can start a script with <? instead of<?php Most people use the long open tag though because it makes their scripts more portable. Also <? is used in other programming languages, if any of those installed on the server, it will try and guess which programming language to use so could end up with problems. The script you have also uses what's known as the ternary operator. This code in your script: <?=isset($_GET['prv'])?'&prv='.$_GET['prv']:''?> Is the same as doing: <?php if(isset($_GET['prv'])) { echo '&prv='; } else { echo ''; } ?> Link to comment https://forums.phpfreaks.com/topic/156470-solved-shorthand-php/#findComment-823925 Share on other sites More sharing options...
tqla Posted May 2, 2009 Author Share Posted May 2, 2009 Thanks the182guy. So is this? <?=isset($_GET['var'])?> The same as? <?php if(isset($_GET['var'] ?> Or is it the same as? <?php echo if(isset($_GET['var'] ?> Link to comment https://forums.phpfreaks.com/topic/156470-solved-shorthand-php/#findComment-823931 Share on other sites More sharing options...
Ken2k7 Posted May 2, 2009 Share Posted May 2, 2009 No, it's the same as <?php echo isset($_GET['var']); ?> Link to comment https://forums.phpfreaks.com/topic/156470-solved-shorthand-php/#findComment-823933 Share on other sites More sharing options...
tqla Posted May 2, 2009 Author Share Posted May 2, 2009 THANKS! Link to comment https://forums.phpfreaks.com/topic/156470-solved-shorthand-php/#findComment-823935 Share on other sites More sharing options...
the182guy Posted May 2, 2009 Share Posted May 2, 2009 I have just editted my first post......... When you do the short open tag with the equals sign after it like this <?=$hello_world?> It echos whatever is between the = and the final ? isset() returns true or false, so if you were to do <?=isset($_GET['var'])?> then it would echo 0 or 1 on the page. Link to comment https://forums.phpfreaks.com/topic/156470-solved-shorthand-php/#findComment-823936 Share on other sites More sharing options...
tqla Posted May 2, 2009 Author Share Posted May 2, 2009 Great explanation the182guy. I fully understand. Thanks. Link to comment https://forums.phpfreaks.com/topic/156470-solved-shorthand-php/#findComment-823949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.