mrherman Posted December 19, 2010 Share Posted December 19, 2010 Hello -- I'm trying to work through a very simple CMS that I found on the web (just for learning purposes). I need some help understanding this line: <table> <form method="POST" action="account.php?mode=save<?=( isset($_REQUEST['id']) ? "&id={$_REQUEST['id']}" : null )?> <? I understand the Method = "POST", but not the "action = " line. Thanks for any help. Quote Link to comment Share on other sites More sharing options...
quelle Posted December 19, 2010 Share Posted December 19, 2010 am i blind or this guy is starting/ending php code with <? ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted December 19, 2010 Share Posted December 19, 2010 The ?: is called the ternary operator. Basically a shorthand if/else conditional. Quote Link to comment Share on other sites More sharing options...
Anti-Moronic Posted December 19, 2010 Share Posted December 19, 2010 First of all <? ?> are short tags. Shouldn't be using them as not all installations have this enabled by default. Second ?: (see pikachu above) ..and: <?=( isset($_REQUEST['id']) ? "&id={$_REQUEST['id']}" : null )?> can be written as <?php echo ( isset($_REQUEST['id']) ? "&id={$_REQUEST['id']}" : null ); ?> or if(isset($_REQUEST['id']){ echo "&id={$_REQUEST['id']}"; }else{ echo null; } Hopefully that will help clarify the line for you. Note: echo null would not be done, you wouldn't use an else. Quote Link to comment Share on other sites More sharing options...
mrherman Posted December 19, 2010 Author Share Posted December 19, 2010 Yes, this clarifies the line. Thanks to all very much this evening! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.