Jump to content

Few Questions...


MemphiS

Recommended Posts

Just out of interest im sure this question has been asked before..

 

Difference?Speed? between print(); and echo();

 

adding () make it slower/faster instead of just going: print ""; or echo "";

 

Just interested...

 

Another question.

 

while coding.. Example:

 

<?php
$go = $_POST['the'];

if ($go==1){ ...code to excute }
?>

/* Other example */

<?php
if ($_POST['the']){ ...code to excute }
?>

 

Just interested if theres any real point to assigning the post to a variable? Save speed by not setting a variable to it?

 

Thanks ;D

Link to comment
Share on other sites

with $_POST/$_GET variables... you almost always want to make them more safe... so... i subscribe to this school of thought

 

<?php
$go = htmlentities($_POST['the']);

if ($go==1){ ...code to excute }
?>

 

in the long run... its really down to the programmer...what works for you... and including the ()'s on print/echo... really arnt necessary... people use em... but i dont see a point in em... just making your code harder to read :-)

Link to comment
Share on other sites

hmm thanks for your reply.. =) i kinda like using the ()  :P makes it neater to read well i find so :)

 

though you could still use $_POST['the']

 

and place

 

$_POST = array_map('htmlentities', $_POST);

 

which would cover all $_POST[]

Link to comment
Share on other sites

also..

 

you can just check the data submited by the user before it goes anywhere.

<?php

if (!ctype_alnum($_POST['the']){ print("Invalid data."); }elseif (ctype_alnum($_POST['the']){ ...code to excute }

?>

hmm :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.