Jun 1st 2010

PHP Cheat Sheet

Tags: ,
Alt Text

Listed below is the code that I use most in PHP. I will be adding to it on an ongoing basis. If you have a question about how to use any of the code please feel free to add a comment at the bottom of the page.

echo
// echo

<?php echo $nfiles; ?>

<?php echo "word"; ?>

Declare the variable as global
<?php global $td; ?>


<?php global $td; ?>
<?php $td = "variable"; ?>

Include
<?php include 'vars.php'; ?>

Send Variables
Form

<input type="hidden" name="varname" value="<?php echo $bee_email; ?>">

$var_value = $_POST['varname'];

Send Variables
URL

<a href="page.php?myNumber=100">Send variables</a>

<?php
$num = $_GET['myNumber'];
?>

stripslashes
Remove \ form the output

echo stripslashes($bee_footer);

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>