schawel Posted March 17, 2006 Share Posted March 17, 2006 <input type="text" name="email" size="35" value="" class="input"> <input type="hidden" name="mail_message" value="<?=$message?>"> <input type="submit" name="sendemail" class="input" value=" Send " onClick="return validate();">I have this code and it looks like shorthand is being used for this. I was handed this code to try and clean it up.<?=$message?> I don't recog this. should it be <?php something = $message;?>I have a whole page full of stuff like thisi.e. ----<?=$val['fieldname']?>or<?=$_GET['id']?>any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/5186-php-shorthand-bad-coding/ Share on other sites More sharing options...
kenrbnsn Posted March 17, 2006 Share Posted March 17, 2006 The "<?=" is shorthand for "<?php echo "Just replace "<?=" with "<? echo " and you should be set.Ken Quote Link to comment https://forums.phpfreaks.com/topic/5186-php-shorthand-bad-coding/#findComment-18409 Share on other sites More sharing options...
schawel Posted March 17, 2006 Author Share Posted March 17, 2006 [!--quoteo(post=355995:date=Mar 17 2006, 12:31 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 17 2006, 12:31 PM) [snapback]355995[/snapback][/div][div class=\'quotemain\'][!--quotec--]The "<?=" is shorthand for "<?php echo "Just replace "<?=" with "<? echo " and you should be set.Ken[/quote]THANKS!!! u da man![!--quoteo(post=355999:date=Mar 17 2006, 12:40 PM:name=schawel)--][div class=\'quotetop\']QUOTE(schawel @ Mar 17 2006, 12:40 PM) [snapback]355999[/snapback][/div][div class=\'quotemain\'][!--quotec--]THANKS!!! u da man![/quote]ONE more thingin my question..i sampled this<?=$message?>shouldn't there also be a semicolon after the variable $message??? Quote Link to comment https://forums.phpfreaks.com/topic/5186-php-shorthand-bad-coding/#findComment-18413 Share on other sites More sharing options...
kenrbnsn Posted March 17, 2006 Share Posted March 17, 2006 No, it is optional if there is only one statement between the tags. Just like if there is only one statement in a statement block the curly braces are optional.Ken Quote Link to comment https://forums.phpfreaks.com/topic/5186-php-shorthand-bad-coding/#findComment-18419 Share on other sites More sharing options...
Barand Posted March 17, 2006 Share Posted March 17, 2006 To be precise, it doesn't matter if there is one or many statements. The last semicolon is implied by the "?>".So this works OK[code]<?phpecho '1';echo '2';echo '3'?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5186-php-shorthand-bad-coding/#findComment-18420 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.