[PHP] Re: Does anyone here use TCPDF?

2009-09-24 Thread Dave M G
Ralph, Paul,

Thank you for responding.

 I don't use TCPDF; I use FPDF, but I imagine the drill is about the same
   
I tried using FPDF, but it did not support UTF-8/Japanese. It claims
some support in the documentation, but after much experimentation, I
verified it does not. That is why I switched to TCPDF.

 What you're asking sounds like you want to *edit* an existing PDF via a
 PHP class,

No, I just want to write on top of it. And that was possible with
FPDI/FPDF, but I had to abandon those as they did not support Japanese.

I attempted to use the same functions as FPDI/FPDF, but they did not
work in TCPDF.

 have a look in the archive of this list. there is a topic writing japanese
 test in an excisting pdf its of 31. of August, this should help
   

That was a thread I started. Things have changed slightly since I now
know that only TCPDF supports Japanese.

So I still need to know if/how to write text into a PDF, like I did with
FPDF, but with TCPDF instead.

If this turns out to not be possible, I am going to be suffering a great
deal.

-- 
Dave M G

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Does anyone here use TCPDF?

2009-09-24 Thread Ralph Deffke
Hi Dave,

if its the case u could do a good deal, why u don't climp urself into the
pdf format? It is nothing else then a presentation format, not magic,
complicated and huge yes, but at the end just a text file. I am not that pdf
specialist, but I know at least for the older pdf formats the enconding is
open and well documented. I have a book on my shelf called 'pdf bible' an it
explains the pdf byte code.

Another idea would be to contact all the companies creating these pdf
converters (html pdf, word-pdf, pdf-word) they should be able to tell u the
answer.

And even may be there is a programm u could use in a OS batch process to put
ur text in.
At least just contact Adobe and ask them how to do it, u might get an
answer.

sorry thats all I have coming up in my mind for now.

ralph_def...@yahoo.de

Dave M G mar...@autotelic.com wrote in message
news:4abb1e10.9070...@autotelic.com...
 Ralph, Paul,

 Thank you for responding.

  I don't use TCPDF; I use FPDF, but I imagine the drill is about the same
 
 I tried using FPDF, but it did not support UTF-8/Japanese. It claims
 some support in the documentation, but after much experimentation, I
 verified it does not. That is why I switched to TCPDF.

  What you're asking sounds like you want to *edit* an existing PDF via a
  PHP class,

 No, I just want to write on top of it. And that was possible with
 FPDI/FPDF, but I had to abandon those as they did not support Japanese.

 I attempted to use the same functions as FPDI/FPDF, but they did not
 work in TCPDF.

  have a look in the archive of this list. there is a topic writing
japanese
  test in an excisting pdf its of 31. of August, this should help
 

 That was a thread I started. Things have changed slightly since I now
 know that only TCPDF supports Japanese.

 So I still need to know if/how to write text into a PDF, like I did with
 FPDF, but with TCPDF instead.

 If this turns out to not be possible, I am going to be suffering a great
 deal.

 -- 
 Dave M G



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Does anyone here use TCPDF?

2009-09-24 Thread Ben Dunlap
 I attempted to use the same functions as FPDI/FPDF, but they did not
 work in TCPDF.

Which functions did you use in FPDF?

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHPlot patch

2009-09-24 Thread Chandana

Hi,

I was using Phplot for a project of mine and I had to do some modifications
in the phplot.php code to show the data values at the peaks of the graph. I
would like to commit the modification code to the phplot repository so that
others can also use it as an inbuilt functionality. 

If I want to commit to the phplot, how may I achieve it?

Thank you
-- 
View this message in context: 
http://www.nabble.com/PHPlot-patch-tp25550789p25550789.html
Sent from the PHP - General mailing list archive at Nabble.com.


Re: [PHP] PHPlot patch

2009-09-24 Thread Sudheer Satyanarayana

On Thursday 24 September 2009 03:33 PM, Chandana wrote:

Hi,

I was using Phplot for a project of mine and I had to do some modifications
in the phplot.php code to show the data values at the peaks of the graph. I
would like to commit the modification code to the phplot repository so that
others can also use it as an inbuilt functionality.

If I want to commit to the phplot, how may I achieve it?
   
As any other project, contact the project developers and offer them your 
patch.



--

With warm regards,
Sudheer. S
Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, 
Personal: http://sudheer.net


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: session.gc_maxlifetime

2009-09-24 Thread Tom Worster
it could be ip address changes. interesting thought.

i think i should add some special logging.

it's a dedicated freebsd server with one app.


On 9/23/09 6:43 PM, Ralph Deffke ralph_def...@yahoo.de wrote:

 finaly we went with a custom cooky handling, however the customers
 requirements where two days.
 
 if u are shure that the server is still the same hardware like it has been 6
 years ago then it might be some client stuff, however if there are other
 applications, pages running (virtual servers) then it would still be to
 consider. mamory and resource management is deep os. again I wouldn't trust
 for that amount of session livetime.
 
 I dont think, putting it down to three hours would help much.
 
 and of course, it could be client side also. Can't you figure out the
 clients?
 and keep in mind that a lot of people connect to UMTS rigzt now, these
 systems deconnect on idle lines and reconect without the users even know it.
 Also a lot of lines change IP address at midnihgt.
 
 cheers
 ralph_def...@yahoo.de
 
 Tom Worster f...@thefsb.org wrote in message
 news:c6e00521.12d98%...@thefsb.org...
 there's a need for long timeouts in this app but could perhaps be reduced
 from 6 to 3 hours.
 
 the sessions are cookie based using php's 'file' handler and
 session.cookie_lifetime=0. the server appears to have plenty of free
 memory
 and appears not to have swapped in nearly a year of uptime. load averages
 indicate a pretty quiet server. there are currently 170 kbyte total in 90
 serialized session files which is typical and not a memory load. the
 distribution of modification times doesn't indicate heavy activity: ~20
 files in the last 15 minutes and 35 in the last hour.
 
 so i think the os can handle this. plus the app ran for 6 years before
 anyone reported being prematurely logged off. i'm looking for other
 possibilities: odd browser behavior, network trouble, ...
 
 
 are there any browsers that have configurable cookie handling policy such
 that they time out a cookie?
 
 one web site i use displays this curious message: For your protection,
 sessions are open for a limited period of time on our website. Please
 sign-on again. NOTE: Your browser may also limit secure connection time,
 and
 automatically log you out independent of our timeout procedure.
 
 that could be referring to browsers timing out an ssl connection. or
 perhaps
 the cookie?
 
 
 btw: when you said in your email you wouldn't trust a long gc_maxlifetime,
 and you would only use a cookie-based solution for long session. did you
 mean that you wouldn't trust php's cookie-based session handler? and you
 would use a custom handler instead?
 
 
 On 9/22/09 4:46 PM, Ralph Deffke ralph_def...@yahoo.de wrote:
 
 Hi Tom,
 
 in sometimes 2001 I did have incidences with those things, and as I
 remember
 over the past years there where some trouble with operating systems and
 stuff. This part is very deep inside the os. I would expect that this is
 still to consider. I also would check, if this occurs on very busy/low
 memory server.
 
 If I would programm the garbage collection clean up part, and if the
 server
 is about to run out of memory, I would kill sessions being longer time
 idle
 even when they are not yet as old as it is set in the gc_maxlifetime.
 This
 would be far better then shutting down the whole server just because
 there a
 100 of idle sessions waiting to get used again.
 
 as u mention a maxlivetime of 6h I would bet, that this is the problem.
 I
 would not trust such a long lifetime at all.
 
 If sessions have to be active such a long time, I would see only cooky
 based
 solutions
 
 let me know, what u did investigate on this.
 
 ralph_def...@yahoo.de
 
 
 Tom Worster f...@thefsb.org wrote in message
 news:c6deae55.12cae%...@thefsb.org...
 thank you, Ralph!
 
 i'm going to be bold and assume that tom at punkave dot com is right
 despite
 that the report was discarded.
 
 i got a complaint from a client about some users reporting being logged
 out
 with rather short periods of inactivity. but session.gc_maxlifetime is
 set
 to 6 hours so i don't think that's the source of the problem.
 
 
 On 9/22/09 4:17 PM, Ralph Deffke ralph_def...@yahoo.de wrote:
 
 Hi Tom,
 
 i did find this in the bug reports, its pretty new and should be an
 answer.
 
 http://news.php.net/php.doc.bugs/2653
 
 ralph_def...@yahoo.de
 
 
 Tom Worster f...@thefsb.org wrote in message
 news:c6de9eee.12c8d%...@thefsb.org...
 i'm not 100% sure what the manual means when it says...
 
 session.gc_maxlifetime integer
 session.gc_maxlifetime specifies the number of seconds after which
 data
 will
 be seen as 'garbage' and cleaned up. Garbage collection occurs during
 session start.
 
 what event exactly does the after which here refer to?
 
 i'd like to think that it means that a session is eligible for gc no
 sooner
 than session.gc_maxlifetime seconds after the most recent access
 (read
 or
 write) to that session. but it seems dangerously presumptuous 

[PHP] catch an iconv E_NOTICE

2009-09-24 Thread Tom Worster
i have this hack that works up to a point...

function my_err_handler($errno, $errstr, $errfile, $errline) {
if ( preg_match('/iconv/', $errstr) ) {
throw new Exception('iconv error');
} else {
// ? how to invoke default error handler ?
}
}
set_error_handler(my_err_handler, E_NOTICE);

try {
$s = iconv($enc1, $enc2, $s);
} catch (Exception $e) {
// deal with the failed conversion
}

but i'd like proceed with default error handling in the branch with the
question marks. how can i do that?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] stdout as input

2009-09-24 Thread Christoph Boget
I've read the section in the docs about i/o streams and other related
sections I was able to find but couldn't figure out how to do what I
need.  From the command line, I'm trying to pipe stdout in to my php
script which should then see it as input.  A simplistic example would
be:

echo bob | myScript.php

In myScript.php, I'm doing:

  $handle = popen( 'php://stdin', 'r' );
  echo var_export( $handle, TRUE ) . \n\n;

I've also tried php://stdout and php://input.  I also tried eschewing
the php:// pseudo protocol and popen altogether and going with the
STDIN and STDOUT constants.  None of that worked.  Is there a way I
can pipe/redirect output from a command line uhh, command as input to
my script?

thnx,
Christoph

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] catch an iconv E_NOTICE

2009-09-24 Thread David Otton
2009/9/24 Tom Worster f...@thefsb.org:

 but i'd like proceed with default error handling in the branch with the
 question marks. how can i do that?

An error handler that passes through to the previous error handler:

?php
error_reporting(E_ALL);

function my_error_handler($errno, $errstr, $errfile, $errline) {
restore_error_handler();
trigger_error($errstr, $errno);
}

set_error_handler('my_error_handler', E_ALL);

trigger_error('TEST', E_USER_ERROR);

You'll lose the file and line, though, because you're actually raising
another error with the same message at a new point in the code.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] catch an iconv E_NOTICE

2009-09-24 Thread Tommy Pham
- Original Message 
 From: Tom Worster f...@thefsb.org
 To: PHP General List php-general@lists.php.net
 Sent: Thursday, September 24, 2009 6:42:29 AM
 Subject: [PHP] catch an iconv E_NOTICE
 
 i have this hack that works up to a point...
 
 function my_err_handler($errno, $errstr, $errfile, $errline) {
 if ( preg_match('/iconv/', $errstr) ) {
 throw new Exception('iconv error');
 } else {
 // ? how to invoke default error handler ?

http://www.php.net/manual/en/function.restore-error-handler.php

 }
 }
 set_error_handler(my_err_handler, E_NOTICE);
 
 try {
 $s = iconv($enc1, $enc2, $s);
 } catch (Exception $e) {
 // deal with the failed conversion
 }
 
 but i'd like proceed with default error handling in the branch with the
 question marks. how can i do that?
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] stdout as input

2009-09-24 Thread Tommy Pham
- Original Message 
 From: Christoph Boget christoph.bo...@gmail.com
 To: PHP General php-general@lists.php.net
 Sent: Thursday, September 24, 2009 6:51:56 AM
 Subject: [PHP] stdout as input
 
 I've read the section in the docs about i/o streams and other related
 sections I was able to find but couldn't figure out how to do what I
 need.  From the command line, I'm trying to pipe stdout in to my php
 script which should then see it as input.  A simplistic example would
 be:
 
 echo bob | myScript.php
 
 In myScript.php, I'm doing:
 
   $handle = popen( 'php://stdin', 'r' );
   echo var_export( $handle, TRUE ) . \n\n;
 
 I've also tried php://stdout and php://input.  I also tried eschewing
 the php:// pseudo protocol and popen altogether and going with the
 STDIN and STDOUT constants.  None of that worked.  Is there a way I
 can pipe/redirect output from a command line uhh, command as input to
 my script?
 
 thnx,
 Christoph
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

Isn't it simpler with
http://www.php.net/manual/en/function.shell-exec.php
?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] stdout as input

2009-09-24 Thread Christoph Boget
 Isn't it simpler with
 http://www.php.net/manual/en/function.shell-exec.php
 ?

Perhaps.  But the command to execute would be relatively arbitrary.
What I'm trying to do is set up a script that will filter the results
of a grep.  But what I'm grepping and where I'm starting from would
change.  I suppose I could pass those arguments to my script and
access it using argv but I'm actually kind of curious how (if) I can
access output which has been piped (or redirected) to my script.

thnx,
Christoph

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: session.gc_maxlifetime

2009-09-24 Thread bdunlap
 it could be ip address changes. interesting thought.

As far as I'm aware, PHP session-management doesn't care about source
IP, out-of-the-box -- your app would have to be coded to care. Plus I
suspect you would have started seeing the problem a long time ago, if
changing source IPs were the cause.

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] stdout as input

2009-09-24 Thread bdunlap
 echo bob | myScript.php

 In myScript.php, I'm doing:

  $handle = popen( 'php://stdin', 'r' );
  echo var_export( $handle, TRUE ) . \n\n;

What output are you getting from those lines, and what were you
expecting? $handle is just a resource, same as if you opened a regular
file -- you still need to read data from it with something like
fgets().

If I'm writing a quick-and-dirty script to process piped-in data, I
find this construct to work reasonably well:

while(!feof(STDIN)) {
$line = fgets(STDIN);

// trim() $line here if I don't want trailing/vertical whitespace

// now do something with $line
}

The one weakness of that form is that I always get an empty line at
the end, but as long as I check for that in the loop (which I should
usually be doing anyway), it's no problem.

Ben

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: session.gc_maxlifetime

2009-09-24 Thread Ralph Deffke
php not but perhaps the client its not clear and commonly defined what
clients do with cookies on reconnect and stuff or long idle times.

I would expect as source the new browsers where more and more users use
subwindows to have concurrent sessions, does anybody know how they handle ip
changes? I'm not.

these things are new and that would fit that the problem is new as well.


bdunlap bdun...@agentintellect.com wrote in message
news:7997e80e0909240851t7f0a2189u4540a09546a85...@mail.gmail.com...
  it could be ip address changes. interesting thought.

 As far as I'm aware, PHP session-management doesn't care about source
 IP, out-of-the-box -- your app would have to be coded to care. Plus I
 suspect you would have started seeing the problem a long time ago, if
 changing source IPs were the cause.

 Ben



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] stdout as input

2009-09-24 Thread Shawn McKenzie
bdunlap wrote:
 echo bob | myScript.php

 In myScript.php, I'm doing:

  $handle = popen( 'php://stdin', 'r' );
  echo var_export( $handle, TRUE ) . \n\n;
 
 What output are you getting from those lines, and what were you
 expecting? $handle is just a resource, same as if you opened a regular
 file -- you still need to read data from it with something like
 fgets().
 
 If I'm writing a quick-and-dirty script to process piped-in data, I
 find this construct to work reasonably well:
 
 while(!feof(STDIN)) {
 $line = fgets(STDIN);
 
 // trim() $line here if I don't want trailing/vertical whitespace
 
 // now do something with $line
 }
 
 The one weakness of that form is that I always get an empty line at
 the end, but as long as I check for that in the loop (which I should
 usually be doing anyway), it's no problem.
 
 Ben

Exactly.  And if you just want redirected data you can try:

$data = file_get_contents(php://stdin);

--or--

For an array of lines:

$lines = file(php://stdin);

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] stdout as input

2009-09-24 Thread Christoph Boget
 Exactly.  And if you just want redirected data you can try:
 $data = file_get_contents(php://stdin);
 --or--
 For an array of lines:
 $lines = file(php://stdin);

This is exactly what I was looking for.  Thanks Shawn and Ben!

thnx,
Christoph

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] catch an iconv E_NOTICE

2009-09-24 Thread Tom Worster
On 9/24/09 10:30 AM, David Otton phpm...@jawbone.freeserve.co.uk wrote:

 2009/9/24 Tom Worster f...@thefsb.org:
 
 but i'd like proceed with default error handling in the branch with the
 question marks. how can i do that?
 
 An error handler that passes through to the previous error handler:
 
 ?php
 error_reporting(E_ALL);
 
 function my_error_handler($errno, $errstr, $errfile, $errline) {
 restore_error_handler();
 trigger_error($errstr, $errno);
 }
 
 set_error_handler('my_error_handler', E_ALL);
 
 trigger_error('TEST', E_USER_ERROR);
 
 You'll lose the file and line, though, because you're actually raising
 another error with the same message at a new point in the code.

and i'd need to set my error handler back again to catch the next iconv
error:

function my_err_handler($errno, $errstr, $errfile, $errline) {
if ( preg_match('/iconv/', $errstr) ) {
throw new Exception('iconv error');
} else {
restore_error_handler();
trigger_error($errstr, $errno);
set_error_handler('my_error_handler', E_ALL);
}
}
set_error_handler('my_error_handler', E_ALL);

not lovely. as it stands, my own code writes the error message to the log
file in that place. i'm not sure this is an improvement.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] variable

2009-09-24 Thread Grega Leskovšek
Suppose I have a variable $i = 0 or 1 or 2
and I have variables $item0, $item1 and $item2
how do I print the variable $item0 using a combination of variable $item and
variable $i?
or with this code it gives me an error:
$i = 0;
$item0 = test;
echo $item$i; #how do I properly use this variable $item with $i?

Thanks in advance, Yours, Grega


-- Peace refuge: http://users.skavt.net/~gleskovs/
When the sun rises I receive and when it sets I forgive;) Grega Leskovšek


Re: [PHP] variable

2009-09-24 Thread Tommy Pham
- Original Message 
 From: Grega Leskovšek legr...@gmail.com
 To: php-general@lists.php.net
 Sent: Thursday, September 24, 2009 10:10:33 AM
 Subject: [PHP] variable
 
 Suppose I have a variable $i = 0 or 1 or 2
 and I have variables $item0, $item1 and $item2
 how do I print the variable $item0 using a combination of variable $item and
 variable $i?
 or with this code it gives me an error:
 $i = 0;
 $item0 = test;
 echo $item$i; #how do I properly use this variable $item with $i?
 
 Thanks in advance, Yours, Grega
 
 
 -- Peace refuge: http://users.skavt.net/~gleskovs/
 When the sun rises I receive and when it sets I forgive;) Grega Leskovšek

${'item'$i} ?  Why not use array? Thus, $item[$i], simplify your life ;)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: session.gc_maxlifetime

2009-09-24 Thread Ben Dunlap
 php not but perhaps the client its not clear and commonly defined what
 clients do with cookies on reconnect and stuff or long idle times.

Maybe not, but I'd be really surprised. An HTTP client is supposed to
decide whether to send a cookie by looking at the domain name and path
of the URL it's requesting. These things are at a totally different
layer from IP addresses -- and even if they weren't, in most cases I
would think a browser is going to be ignorant of public IP address
changes because it's going to be behind a NAT device.

 I would expect as source the new browsers where more and more users use
 subwindows to have concurrent sessions, does anybody know how they handle ip
 changes? I'm not.

What specific situation do you have in mind in which a browser would
even be aware of an IP change on the client side? Maybe there are
common cases I'm not thinking of.

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] variable

2009-09-24 Thread Tommy Pham




- Original Message 
 From: Tommy Pham tommy...@yahoo.com
 To: Grega Leskovšek legr...@gmail.com; php-general@lists.php.net
 Sent: Thursday, September 24, 2009 10:16:44 AM
 Subject: Re: [PHP] variable
 
 - Original Message 
  From: Grega Leskovšek 
  To: php-general@lists.php.net
  Sent: Thursday, September 24, 2009 10:10:33 AM
  Subject: [PHP] variable
  
  Suppose I have a variable $i = 0 or 1 or 2
  and I have variables $item0, $item1 and $item2
  how do I print the variable $item0 using a combination of variable $item and
  variable $i?
  or with this code it gives me an error:
  $i = 0;
  $item0 = test;
  echo $item$i; #how do I properly use this variable $item with $i?
  
  Thanks in advance, Yours, Grega
  
  
  -- Peace refuge: http://users.skavt.net/~gleskovs/
  When the sun rises I receive and when it sets I forgive;) Grega Leskovšek
 
 ${'item'$i} ?  Why not use array? Thus, $item[$i], simplify your life ;)
 
Typed too slow... my mistake. It should be:

${'item' . $i}

 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] variable

2009-09-24 Thread Ben Dunlap
 Suppose I have a variable $i = 0 or 1 or 2
 and I have variables $item0, $item1 and $item2
 how do I print the variable $item0 using a combination of variable $item and
 variable $i?
 or with this code it gives me an error:
 $i = 0;
 $item0 = test;
 echo $item$i; #how do I properly use this variable $item with $i?

   $var = item$i;
   echo $$var;

Note the two dollar-signs in the second line.

I wonder if a basic array would make for easier-to-read code, though:

$items = array( test );
$i = 0;
echo $items[$i];

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] variable

2009-09-24 Thread Lars Nielsen
Hi Grega

I think you might want to have a look at the array's section of the php
manual.
http://www.php.net/array

regards Lars

tor, 24 09 2009 kl. 19:10 +0200, skrev Grega Leskovšek:
 Suppose I have a variable $i = 0 or 1 or 2
 and I have variables $item0, $item1 and $item2
 how do I print the variable $item0 using a combination of variable $item and
 variable $i?
 or with this code it gives me an error:
 $i = 0;
 $item0 = test;
 echo $item$i; #how do I properly use this variable $item with $i?
 
 Thanks in advance, Yours, Grega
 
 
 -- Peace refuge: http://users.skavt.net/~gleskovs/
 When the sun rises I receive and when it sets I forgive;) Grega Leskovšek


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] html email showing br instead of line breaks

2009-09-24 Thread Adam Williams
I have users enter support tickets into a a textarea form and then it 
emails it to me, I'm trying to get the emails to display when they hit 
enter correctly, so i'm changing the \r\n to br, but in the email i'm 
getting, its displaying the br instead of a line break:  here is the code:


$message = htmlheadtitlenew support request 
#.mysqli_insert_id($mysqli)./title/headbodyp
Hello, .$_SESSION[full_name]. has created a  new support request.  
Please log in at a href=\http://intra/helpdesk\;MDAH Helpdesk/a. 
The problem request is \;
$message .= htmlspecialchars(str_replace('\r\n', 'br', 
$_POST[problem]));
$message .= \ and the best time to contact is 
\.htmlspecialchars($_POST[contact_time]).\ /p/body/html;

   $headers  = 'MIME-Version: 1.0' . \r\n;
   $headers .= 'Content-type: text/html; 
charset=iso-8859-1' . \r\n;
   $headers .= From: 
.$_SESSION[full_name]..$_SESSION[username].@mdah.state.ms.us 
.\r\n .

   X-Mailer: PHP/ . phpversion();
  mail('isst...@mdah.state.ms.us', $subject, $message, 
$headers);


but the email I get is:

Hello, Karen Redhead has created a new support request. Please log in at 
MDAH Helpdesk http://intra/helpdesk. The problem request is Elaine is 
out today but her computer no longer has Past Perfect from what I can 
tell. Also how does she access her email. The Sea Monkey email icon does 
not take you anywhere.brThanks so much,brKaren and the best time to 
contact is 1:30 -5:00



How come the email is being displayed with br instead of line breaks?



Re: [PHP] html email showing br instead of line breaks

2009-09-24 Thread Jonathan Tapicer
\r\n should be between double quotes: \r\n

On Thu, Sep 24, 2009 at 3:52 PM, Adam Williams
awill...@mdah.state.ms.us wrote:
 I have users enter support tickets into a a textarea form and then it
 emails it to me, I'm trying to get the emails to display when they hit enter
 correctly, so i'm changing the \r\n to br, but in the email i'm getting,
 its displaying the br instead of a line break:  here is the code:

 $message = htmlheadtitlenew support request
 #.mysqli_insert_id($mysqli)./title/headbodyp
 Hello, .$_SESSION[full_name]. has created a  new support request.
  Please log in at a href=\http://intra/helpdesk\;MDAH Helpdesk/a. The
 problem request is \;
 $message .= htmlspecialchars(str_replace('\r\n', 'br',
 $_POST[problem]));
 $message .= \ and the best time to contact is
 \.htmlspecialchars($_POST[contact_time]).\ /p/body/html;
               $headers  = 'MIME-Version: 1.0' . \r\n;
               $headers .= 'Content-type: text/html; charset=iso-8859-1' .
 \r\n;
               $headers .= From:
 .$_SESSION[full_name]..$_SESSION[username].@mdah.state.ms.us
 .\r\n .
               X-Mailer: PHP/ . phpversion();
              mail('isst...@mdah.state.ms.us', $subject, $message, $headers);

 but the email I get is:

 Hello, Karen Redhead has created a new support request. Please log in at
 MDAH Helpdesk http://intra/helpdesk. The problem request is Elaine is out
 today but her computer no longer has Past Perfect from what I can tell. Also
 how does she access her email. The Sea Monkey email icon does not take you
 anywhere.brThanks so much,brKaren and the best time to contact is 1:30
 -5:00


 How come the email is being displayed with br instead of line breaks?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] html email showing br instead of line breaks

2009-09-24 Thread Adam Williams
Thanks, i'll try that.  what is the difference in using '' and ?  I 
thought they were interchangeable.


Jonathan Tapicer wrote:

\r\n should be between double quotes: \r\n

  



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] RIGHT Function?

2009-09-24 Thread sono-io

Hi all,

	I could use some help.  I've scoured both the MySQL and PHP sites  
that I know of and can't find an answer to this.


I have a price field that sometimes contains entries like this:

250,(min)
5.32

	How can I pull just the price ($5.32 in this example) from this field  
to display on a web page?  Is there a RIGHT function in PHP?  When I  
search the PHP site, I'm being told there isn't one.


Here's the code I've been using:

?php $result = mysql_query(SELECT priceList,unitprice FROM catalog  
WHERE itemid='WR-1240',$db);
printf('List: $%sbr /', number_format(mysql_result($result, 
0,priceList),2));
printf('Your Price: $%s', number_format(mysql_result($result, 
0,unitprice),2)); ?


Thanks,
Frank

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] html email showing br instead of line breaks

2009-09-24 Thread Adam Williams
oh nevermind, i see double quotes translate the \r\n to its appropriate 
EOL character.


Adam Williams wrote:
Thanks, i'll try that.  what is the difference in using '' and ?  I 
thought they were interchangeable.


Jonathan Tapicer wrote:

\r\n should be between double quotes: \r\n

  






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] html email showing br instead of line breaks

2009-09-24 Thread Jonathan Tapicer
Double quotes accept special characters and string interpolation, see
the manual: http://php.net/manual/en/language.types.string.php

On Thu, Sep 24, 2009 at 4:00 PM, Adam Williams
awill...@mdah.state.ms.us wrote:
 Thanks, i'll try that.  what is the difference in using '' and ?  I
 thought they were interchangeable.

 Jonathan Tapicer wrote:

 \r\n should be between double quotes: \r\n




 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] RIGHT Function?

2009-09-24 Thread Tommy Pham
 Original Message 
 From: sono...@fannullone.us sono...@fannullone.us
 To: PHP General List php-general@lists.php.net
 Sent: Thursday, September 24, 2009 12:01:41 PM
 Subject: [PHP] RIGHT Function?
 
 Hi all,
 
 I could use some help.  I've scoured both the MySQL and PHP sites that I 
 know of and can't find an answer to this.
 
 I have a price field that sometimes contains entries like this:
 
 250,(min)
 5.32

regex? If 250,(min)5.32 is in your row data, how do you sort price 
ascending/descending?

 
 How can I pull just the price ($5.32 in this example) from this field to 
 display on a web page?  Is there a RIGHT function in PHP?  When I search the 
 PHP 
 site, I'm being told there isn't one.
 
 Here's the code I've been using:
 
  itemid='WR-1240',$db);
 printf('List: $%s
', number_format(mysql_result($result,0,priceList),2));
 printf('Your Price: $%s', 
 number_format(mysql_result($result,0,unitprice),2)); 
 ?
 
 Thanks,
 Frank
 
 --PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] html email showing br instead of line breaks

2009-09-24 Thread Fernando Castillo Aparicio
Have you tried http://es.php.net/manual/en/function.nl2br.php ?

I think it's easier and fits your needs.





De: Adam Williams awill...@mdah.state.ms.us
Para: PHP General list php-general@lists.php.net
Enviado: jueves, 24 de septiembre, 2009 20:52:13
Asunto: [PHP] html email showing br instead of line breaks

I have users enter support tickets into a a textarea form and then it emails 
it to me, I'm trying to get the emails to display when they hit enter 
correctly, so i'm changing the \r\n to br, but in the email i'm getting, its 
displaying the br instead of a line break:  here is the code:

$message = htmlheadtitlenew support request 
#.mysqli_insert_id($mysqli)./title/headbodyp
Hello, .$_SESSION[full_name]. has created a  new support request.  Please 
log in at a href=\http://intra/helpdesk\;MDAH Helpdesk/a. The problem 
request is \;
$message .= htmlspecialchars(str_replace('\r\n', 'br', $_POST[problem]));
$message .= \ and the best time to contact is 
\.htmlspecialchars($_POST[contact_time]).\ /p/body/html;
   $headers  = 'MIME-Version: 1.0' . \r\n;
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . 
\r\n;
   $headers .= From: 
.$_SESSION[full_name]..$_SESSION[username].@mdah.state.ms.us .\r\n 
.
   X-Mailer: PHP/ . phpversion();
  mail('isst...@mdah.state.ms.us', $subject, $message, $headers);

but the email I get is:

Hello, Karen Redhead has created a new support request. Please log in at MDAH 
Helpdesk http://intra/helpdesk. The problem request is Elaine is out today 
but her computer no longer has Past Perfect from what I can tell. Also how does 
she access her email. The Sea Monkey email icon does not take you 
anywhere.brThanks so much,brKaren and the best time to contact is 1:30 
-5:00


How come the email is being displayed with br instead of line breaks?


  

Re: [PHP] html email showing br instead of line breaks

2009-09-24 Thread Ben Dunlap
 \r\n should be between double quotes: \r\n

I think you'll still see the literal brs in your final email,
though because htmlspecialchars() is converting the angle-brackets in
the tag to their respective HTML entities (lt; for  and gt;
for ).

A bit of a thorny problem because you probably do want to escape
HTML-characters in the message for security purposes. I suppose you
could call str_replace() after htmlspecialchars(), instead of before
it as you currently do.

OTOH, why not just send your email as plain text, instead of HTML?

Thanks,

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] RIGHT Function?

2009-09-24 Thread Jay Blanchard
[snip]
I have a price field that sometimes contains entries like this:

250,(min)
5.32

How can I pull just the price ($5.32 in this example) from this
field  
to display on a web page?  Is there a RIGHT function in PHP?  When I  
search the PHP site, I'm being told there isn't one.

Here's the code I've been using:
[/snip]

substr will work from right to left.

If your data is in a variable do this;

echo substr($myData, -5);

Why -5? To account for 2 decimal places, the decimal and up to 99
dollars?

http://www.php.net/substr

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] RIGHT Function?

2009-09-24 Thread Tommy Pham
- Original Message 
 From: Jay Blanchard jblanch...@pocket.com
 To: sono...@fannullone.us; PHP General List php-general@lists.php.net
 Sent: Thursday, September 24, 2009 12:15:13 PM
 Subject: RE: [PHP] RIGHT Function?
 
 [snip]
 I have a price field that sometimes contains entries like this:
 
 250,(min)
 5.32
 
 How can I pull just the price ($5.32 in this example) from this
 field  
 to display on a web page?  Is there a RIGHT function in PHP?  When I  
 search the PHP site, I'm being told there isn't one.
 
 Here's the code I've been using:
 [/snip]
 
 substr will work from right to left.
 
 If your data is in a variable do this;
 
 echo substr($myData, -5);
 
 Why -5? To account for 2 decimal places, the decimal and up to 99
 dollars?
 
 http://www.php.net/substr
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

http://dev.mysql.com/doc/refman/5.1/en/string-functions.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] RIGHT Function?

2009-09-24 Thread Tommy Pham
- Original Message 
 From: Tommy Pham tommy...@yahoo.com
 To: PHP General List php-general@lists.php.net
 Sent: Thursday, September 24, 2009 12:19:51 PM
 Subject: Re: [PHP] RIGHT Function?
 
 - Original Message 
  From: Jay Blanchard 
  To: sono...@fannullone.us; PHP General List 
  Sent: Thursday, September 24, 2009 12:15:13 PM
  Subject: RE: [PHP] RIGHT Function?
  
  [snip]
  I have a price field that sometimes contains entries like this:
  
  250,(min)
  5.32
  
  How can I pull just the price ($5.32 in this example) from this
  field  
  to display on a web page?  Is there a RIGHT function in PHP?  When I  
  search the PHP site, I'm being told there isn't one.
  
  Here's the code I've been using:
  [/snip]
  
  substr will work from right to left.
  
  If your data is in a variable do this;
  
  echo substr($myData, -5);
  
  Why -5? To account for 2 decimal places, the decimal and up to 99
  dollars?
  
  http://www.php.net/substr
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 http://dev.mysql.com/doc/refman/5.1/en/string-functions.html

If you want to retain the ',(min)' for other uses, you'll have to do it in PHP

http://www.php.net/manual/en/ref.strings.php

stripos() and substr() will do it if you don't want to deal with/learn regex


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] RIGHT Function?

2009-09-24 Thread sono-io


On Sep 24, 2009, at 12:15 PM, Jay Blanchard wrote:


substr will work from right to left.

If your data is in a variable do this;


Thanks, Jay.  That does the job.

Frank

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Downloader help needed :-(

2009-09-24 Thread Chris Payne
HI everyone,

Thanks for those of you in the past that helped me with my downloader
not displaying the filename.  Someone gave me a link to the downloader
below which works GREAT but i've tried and tried to limit the data
transfer to 60KB a second andI can't get it to work, can any of you
see what I could add to get it to work?  The first peice of code the
code I WANT to use as it lets me download with the correct filename
etc .. but the second piece of code allows me to limit the speed
of the transfer but when I try to merge the second with the first it
craps out on me.

Any help would REALLY be appreciated on this one.

Thanks everyone.

Piece of code 1 (Code I WANT to use)

function forceDownload($file) {
/**
 * Function forceDownload:
 *  download any type of file if it exists and is readable
 * -
 * @author  Andrea Giammarchi
 * @date18/01/2005 [17/05/2006]
 * @compatibility   PHP = 4.3.0
 */
if(file_exists($file)  is_readable($file)) {
$filename = basename($file);
if(strpos(strtoupper($_SERVER['HTTP_USER_AGENT']), 'MSIE') !== 
false
 strpos($filename, '.') !== false) {
$parsename = explode('.', $filename);
$last = count($parsename) - 1;
$filename = implode('%2E', array_slice($parsename, 0, 
$last));
$filename .= '.'.$parsename[$last];
};
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; 
filename='.$filename.'');
header('Content-Length:'.filesize($file));
header('Content-Transfer-Encoding: binary');
if(@$file = fopen($file, rb)) {
while(!feof($file))
echo fread($file, 8192);
fclose($file);
};
exit(0);
};

};

Piece of code 2 (Which limits nice but has other issues)

$speed = 60; // i.e. 60 kb/s download rate
if(file_exists($file)  is_file($file)) {
   header(Cache-control: private);
   header(Content-Type: application/octet-stream);
   header(Content-Length: .filesize($file));
   //header(Content-Disposition: filename=$file . %20);

   header(Content-Disposition: attachment; filename=\$file\);

   flush();
   $fd = fopen($file, r);
   while(!feof($fd)) {
  echo fread($fd, round($speed*1024)); // $speed kb at a time
  flush();
  sleep(1);
   }
   fclose ($fd);
}

Thank you everyone, it's really appreciated.

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Downloader help needed :-(

2009-09-24 Thread Tommy Pham
- Original Message 

 From: Chris Payne chris_pa...@danmangames.com
 To: php-general@lists.php.net
 Sent: Thursday, September 24, 2009 2:57:57 PM
 Subject: [PHP] Downloader help needed :-(
 
 HI everyone,
 
 Thanks for those of you in the past that helped me with my downloader
 not displaying the filename.  Someone gave me a link to the downloader
 below which works GREAT but i've tried and tried to limit the data
 transfer to 60KB a second andI can't get it to work, can any of you
 see what I could add to get it to work?  The first peice of code the
 code I WANT to use as it lets me download with the correct filename
 etc .. but the second piece of code allows me to limit the speed
 of the transfer but when I try to merge the second with the first it
 craps out on me.
 
 Any help would REALLY be appreciated on this one.
 
 Thanks everyone.
 
 Piece of code 1 (Code I WANT to use)
 
 function forceDownload($file) {
 /**
  * Function forceDownload:
  *download any type of file if it exists and is readable
  * -
  * @authorAndrea Giammarchi
  * @date18/01/2005 [17/05/2006]
  * @compatibilityPHP = 4.3.0
  */
 if(file_exists($file)  is_readable($file)) {
 $filename = basename($file);
 if(strpos(strtoupper($_SERVER['HTTP_USER_AGENT']), 'MSIE') !== false
  strpos($filename, '.') !== false) {
 $parsename = explode('.', $filename);
 $last = count($parsename) - 1;
 $filename = implode('%2E', array_slice($parsename, 0, $last));
 $filename .= '.'.$parsename[$last];
 };
 header('Content-Type: application/octet-stream');
 header('Content-Disposition: attachment; filename='.$filename.'');
 header('Content-Length:'.filesize($file));
 header('Content-Transfer-Encoding: binary');

$speed = 60; // i.e. 60 kb/s download rate

 if(@$file = fopen($file, rb)) {
 while(!feof($file))
{
//echo fread($file, 8192);
  echo fread($fd, round($speed*1024)); // $speed kb at a time
  flush();
  sleep(1);
}
fclose($file);

 };


 exit(0);
 };
 
 };
 
 Piece of code 2 (Which limits nice but has other issues)
 
 $speed = 60; // i.e. 60 kb/s download rate
 if(file_exists($file)  is_file($file)) {
header(Cache-control: private);
header(Content-Type: application/octet-stream);
header(Content-Length: .filesize($file));
//header(Content-Disposition: filename=$file . %20);
 
header(Content-Disposition: attachment; filename=\$file\);
 
flush();
$fd = fopen($file, r);
while(!feof($fd)) {
   echo fread($fd, round($speed*1024)); // $speed kb at a time
   flush();
   sleep(1);
}
fclose ($fd);
 }
 
 Thank you everyone, it's really appreciated.
 
 Chris
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

Try the above changes.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Downloader help needed :-(

2009-09-24 Thread Tommy Pham
- Original Message 
 From: Tommy Pham tommy...@yahoo.com
 To: php-general@lists.php.net
 Sent: Thursday, September 24, 2009 4:19:48 PM
 Subject: Re: [PHP] Downloader help needed :-(
 
 - Original Message 
 
  From: Chris Payne 
  To: php-general@lists.php.net
  Sent: Thursday, September 24, 2009 2:57:57 PM
  Subject: [PHP] Downloader help needed :-(
  
  HI everyone,
  
  Thanks for those of you in the past that helped me with my downloader
  not displaying the filename.  Someone gave me a link to the downloader
  below which works GREAT but i've tried and tried to limit the data
  transfer to 60KB a second andI can't get it to work, can any of you
  see what I could add to get it to work?  The first peice of code the
  code I WANT to use as it lets me download with the correct filename
  etc .. but the second piece of code allows me to limit the speed
  of the transfer but when I try to merge the second with the first it
  craps out on me.
  
  Any help would REALLY be appreciated on this one.
  
  Thanks everyone.
  
  Piece of code 1 (Code I WANT to use)
  
  function forceDownload($file) {
  /**
   * Function forceDownload:
   *download any type of file if it exists and is readable
   * -
   * @authorAndrea Giammarchi
   * @date18/01/2005 [17/05/2006]
   * @compatibilityPHP = 4.3.0
   */
  if(file_exists($file)  is_readable($file)) {
  $filename = basename($file);
  if(strpos(strtoupper($_SERVER['HTTP_USER_AGENT']), 'MSIE') !== false
   strpos($filename, '.') !== false) {
  $parsename = explode('.', $filename);
  $last = count($parsename) - 1;
  $filename = implode('%2E', array_slice($parsename, 0, $last));
  $filename .= '.'.$parsename[$last];
  };
  header('Content-Type: application/octet-stream');
  header('Content-Disposition: attachment; filename='.$filename.'');
  header('Content-Length:'.filesize($file));
  header('Content-Transfer-Encoding: binary');
 
 $speed = 60; // i.e. 60 kb/s download rate
 
  if(@$file = fopen($file, rb)) {
  while(!feof($file))
 {
 //echo fread($file, 8192);
   echo fread($fd, round($speed*1024)); // $speed kb at a time

Sorry, still not wide awake from my afternoon nap...
The above should read:

echo fread($file, round($speed*1024)); // $speed kb at a time

   flush();
   sleep(1);
 }
 fclose($file);
 
  };
 
 
  exit(0);
  };
  
  };
  
  Piece of code 2 (Which limits nice but has other issues)
  
  $speed = 60; // i.e. 60 kb/s download rate
  if(file_exists($file)  is_file($file)) {
 header(Cache-control: private);
 header(Content-Type: application/octet-stream);
 header(Content-Length: .filesize($file));
 //header(Content-Disposition: filename=$file . %20);
  
 header(Content-Disposition: attachment; filename=\$file\);
  
 flush();
 $fd = fopen($file, r);
 while(!feof($fd)) {
echo fread($fd, round($speed*1024)); // $speed kb at a time
flush();
sleep(1);
 }
 fclose ($fd);
  }
  
  Thank you everyone, it's really appreciated.
  
  Chris
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 Try the above changes.
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Downloader help needed :-(

2009-09-24 Thread Chris Payne
Hi there,

Thank you Tommy, I will look at this when my little 3 year old devil
is in bed, I appreciate your help :-)

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] Re: How to take output from an include, and embed it into a variable?

2009-09-24 Thread Carl Furst



Jim Lucas wrote:

Ashley Sheridan wrote:
  

On Wed, 2009-09-23 at 07:36 -0700, Jim Lucas wrote:


Mert Oztekin wrote:
  

Output buffering will do it.

Also I am not sure but did you try retrieving content with fopen() ?

Something like

$file = 'invoicetable_bottom.php';
fopen(http://yoursite.com/folder/$file,r;);

http://tr.php.net/function.fopen

worth trying. Easier than output buffering



This would not work.  fopen would open the file for read.  What you would be
reading is the actual source of the document.  Not the data the script would
output when ran.

The ob_* functions are the only way that I know of to do what you are asking

  

-Original Message-
From: Puiu Hrenciuc [mailto:hp...@xentra.ro]
Sent: Wednesday, September 23, 2009 1:36 PM
To: php-general@lists.php.net
Subject: [PHP] Re: How to take output from an include, and embed it into a 
variable?

Hi,

The simplest way (actually the single way I know :) ) would be to
capture the output using output buffering functions, something like this:

// start output buffering
ob_start();

// include the file that generates the HTML (or whatever content)
include ;

// get output buffer content
$output=ob_get_contents();

// clean output buffer and stop buffering
ob_end_clean();

// the content generated in the included file is now in $output variable
// use it as you consider fit
.


Regards,
Puiu


Rob Gould wrote:


I have an invoice table that is drawn on a number of pages, so I have
all the logic in an include-file like this:

include invoicetable_bottom.php;


However, now I'm needing to take the output from that include file and
pass it as an email.  To do that, I need to somehow take the output from
this include file and get it into a variable somehow.  Is there a simple
way to do this?

Something like:  $emailtcontent = include invoicetable_bottom.php?
  

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

  

That's just crazy talk. If you use fopen on a web URL, then it will
always return the output the script generates. That's how http works!




Sorry, my bad.  Ash is correct, the method that is suggested will work.  But you
will need to enable options in your php.ini that are not on by default for
security reasons, plus as Ben points out, you will need to filter out the scruff
that is generated to capture just the data output from your include.

Mind you that all of this also requires that the file that you are including is
accessible via the web.  It could be in a folder that is not web accessible.

Sorry for the initial confusion!

  

Thanks,
Ash
http://www.ashleysheridan.co.uk







  
Do you have php configured to compile files? Why not just backtick the 
php -f command??


?

$cmd = *escapeshellcmd*(/full/path/to/php -f $file);
$email_output = `$cmd`;

# do something with $email_output

?

Seems easier than a whole http call.. can be risky if the $file variable 
can be set by user input (big no no), but other than that.. seeems the 
simplest.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php