You are here: Re: [PHP] Re: How to read PHP variables. « PHP « IT news, forums, messages
Re: [PHP] Re: How to read PHP variables.

Posted by Edward Vermillion on 11/13/31 11:21

Bruno B B Magalhães wrote:
> Hi everybody,
>
> well I don´t want to include and use those variables or set then. I
> want to read the file, parse the vars to a form, so the user can change
> the system configs using the web instead of FTP...
>
> I am thinking reading using a simple include, and then clean the file
> contents and write the strings..
>
> Best Regards,
> Bruno B B Magalhães
>
One simple way that I've done that in the past is to have a file, which
is a basic php file like:

<?php

$INFO['prefix_sectionInForm'] = 'whatever';

?>


Include that file then do

foreach( $INFO as $in_key => $in_val )
{
if( preg_match("/prefix_/", $in_key) )
{
$db_info[$in_key] = $in_val;
}
}
foreach( $db_info as $in_key => $in_val )
{
$text = ucfirst(substr( $in_key, however long the prefix is ));
$print "Some descroptor based on the prefix".$text
<input type='text' name='$in_key' value='in_val' />
}

Then just write it all back out on the form processor part, with some
security checking of course:

$file_string = "<?php\n";

$update is an array with the key values I want..

foreach( $update as $info_key )
{
foreach( $input as $in_key => $in_val )
{
if( $info_key == $in_key )
{
$new[$info_key] = $in_val;
}
}
}

foreach( $new as $k => $v )
{
$file_string .= "\$INFO["."'".$k."'"."]\t\t\t=\t\"".$v."\";\n";
}

$file_string .= "\n".'?'.'>';

Write $file_string back out to the config file.

Like I said, there's more to the script than this, error checks, seurity
checks and the like, but this is the 'meat' of it all.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация