Jump to content

Recommended Posts

But the syntax is wrong and you can't include a, variable... but you can echo it.. Im guessing you want somthing more like this:

 

  <?php
    $a = '2';
    if($_POST['number']==1){echo $a;}
  ?>

 

Or if you are actualy trying to include a file, do what Kira said.

Just out of curiosity,

 

How does

<?php
$file = 'filename.php';
if (isset($_POST['number']) && $_POST['number'] == '1')
{    
include($file);
}
?>

 

And

<?php    
$a = '2';    
if($_POST['number']==1){echo $a;}  
?>

 

do what you want?  They perform completely different actions?

 

Our if statements are basically the same.  All I did was check that it's set, and that it equals the value you want.

 

The variables are just strings, except mine has ".php" on the end of it which usually means you're pointing it to a file.  What you name the variable really don't matter.

 

Inside the if statements are what actually makes the difference.  His echoes the variable, which prints it out, and mine includes the variable, which pulls the data from the file in the variable to the file it's included in.

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.