Jump to content

How to write this $_POST statement?


ollie007

Recommended Posts

In which case yes, you need the dollar sign.

 

If $type is a string, and the string references one of the keys in $_POST it should work fine the way you originally posted.

 

<?php
//assuming name has been sent via post
$type = 'name';
$name = $_POST[$type];
echo $name;

 

If you are in a development environment and have errors on, you will see an error if the key does not exist.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.