faqts : Computers : Programming : Languages : PHP : Common Problems : HTTP Headers

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

33 of 50 people (66%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

Can variables be included in a header? Like header("Location: $dir")

Jun 20th, 2001 08:14
Philip Olson, Gijsbert te Riet, Jose Luis Pellicer, Ben Udall,


Yes this can. All variables used within double quotes ("") are parsed 
and will be replaced by their values. So, if you have a piece of code 
like this:
  <?php
    $dir = '/photos/';
    header("Location: $dir");
  ?>
Then. PHP will translate "Location: $dir" to :
  "Location: /photos/"
Another example can be seen here :
  http://www.faqts.com/knowledge-base/view.phtml/aid/4127/