Jump to content

Using include() with variables


itsjareds

Recommended Posts

How do you set a variable to what is in a php file?

 

I have a list of numbers that will be put into an array. One file, which has the list of numbers, will be changed often.

 

numbers.php

123.4.567.890, 098.7.654.321

 

myscript.php

<?php 

$ips = <?php include("numbers.php") ?>;

$banned = Array();
$banned[] = $ips;
      
if (in_array($_SERVER['REMOTE_ADDR'], $banned))
  { 
  exit("<center><h2>You are banned from this board.</h2></center>");
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/110775-using-include-with-variables/
Share on other sites

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.