[PHP-DEV] R: [PHP-DEV] python dictionary-like % (percent) substitution in php

2001-08-28 Thread ---

Yes, the function you have written below make the same thing but i think
that a function written in c, inside the php module, can be faster and more
elegant than this php-function.

Again, i think that the final user will be happy to have an already written
function
instead of think and code a personalized function.

I think it's more elegant because it follow the same approach of printf-like
functions
and a user who already known these functions or known python will not have
headaches
in finding a solution for his problem

Also prinf, sprinf, etc... can be written as php functions and separated
from php core, but
it will not happen... why? too important and too useful, they requires speed
and their functionality
is required in many programs.

The same thing happen in python with dictionary substitution, and now,
nobody think to remove
it.

I think that this type of function could be useful for a lot of people...

Let me know what do you (also zeev and others) think about

-
Federico Marani
[EMAIL PROTECTED]
--

Jo Giraerts [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]
 This is already possible in php, though with the following simple
 function..

// function to read a file with php-vars in as a string
// $predefined_vars: an array (varname = value). all the
// variablenames defined in this array can be used in the bodyfile.
// They will receive the respective values. This makes personalising
// the mailes easier..
function file_as_body($filename, $predefined_vars)
{
   $ar = file($filename);
   extract($predefined_vars);

   foreach ($ar as $number = $line)
   {
  eval(\$ar2[] = \$line\;);
   }

   return implode(,$ar2);
}

 and for instance this file as template:

 --- template file
 You received a file on ( . date(d/m/Y (H:i)) . )

 filename: .basename($file) .
 filesize: .filesize($file) .
 mimetype: $mimetype

 Hope you enjoy it..
 ---

 You can even use php-code already, thanks to eval :)

 Maybe we better make it a PEAR-thing?








-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] R: [PHP-DEV] python dictionary-like % (percent) substitution in php

2001-08-28 Thread Jo Giraerts

True. you got a point here. i'll stop bitching :)



On Tue, Aug 28, 2001 at 04:46:35PM +0200,  wrote:
 Yes, the function you have written below make the same thing but i think
 that a function written in c, inside the php module, can be faster and more
 elegant than this php-function.
 
 Again, i think that the final user will be happy to have an already written
 function
 instead of think and code a personalized function.
 
 I think it's more elegant because it follow the same approach of printf-like
 functions
 and a user who already known these functions or known python will not have
 headaches
 in finding a solution for his problem
 
 Also prinf, sprinf, etc... can be written as php functions and separated
 from php core, but
 it will not happen... why? too important and too useful, they requires speed
 and their functionality
 is required in many programs.
 
 The same thing happen in python with dictionary substitution, and now,
 nobody think to remove
 it.
 
 I think that this type of function could be useful for a lot of people...
 
 Let me know what do you (also zeev and others) think about
 
 -
 Federico Marani
 [EMAIL PROTECTED]
 --
 
 Jo Giraerts [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]
  This is already possible in php, though with the following simple
  function..
 
 // function to read a file with php-vars in as a string
 // $predefined_vars: an array (varname = value). all the
 // variablenames defined in this array can be used in the bodyfile.
 // They will receive the respective values. This makes personalising
 // the mailes easier..
 function file_as_body($filename, $predefined_vars)
 {
$ar = file($filename);
extract($predefined_vars);
 
foreach ($ar as $number = $line)
{
   eval(\$ar2[] = \$line\;);
}
 
return implode(,$ar2);
 }
 
  and for instance this file as template:
 
  --- template file
  You received a file on ( . date(d/m/Y (H:i)) . )
 
  filename: .basename($file) .
  filesize: .filesize($file) .
  mimetype: $mimetype
 
  Hope you enjoy it..
  ---
 
  You can even use php-code already, thanks to eval :)
 
  Maybe we better make it a PEAR-thing?
 
 
 
 
 
 
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
Jo Giraerts
Computerprutser
Life BVBA
Interleuvenlaan 15A, 3001 LEUVEN, BELGIUM
icq:81939849, email:[EMAIL PROTECTED], ph0ne:+32(0)16 20 89 61 
pgp-key available at: http://www.keyserver.net. 
fingerprint: 81EE B1FD 88E2 A03A 4F49 6D8A 806E 2220 9C2F 918B 

I've got these opium queens that move around my space, 
I said it's waste not, want not, 
I think I'll take another, 
I'm holding all this pain that I'm trying to smother.
branvan3000 - 
Afrodisiac

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]