Siddhartha rao Siddhartha rao - 18 days ago 5
PHP Question

Page name as a php variable

I am working on a project that requires me to redirect the user to a php page. And the name of the page to be redirected to is stored as a php variable.This is what I tried. Suppose

is the name of the php file. I want to do something like this,

header("Location: '$var'.php");

How do I do this?


You simply need to follow string concatenation here. Try this:

if (condition) {
    header("Location: ".$var.".php"); 

Refer to String Operators