php-general Digest 26 Sep 2009 02:24:04 -0000 Issue 6358

Topics (messages 298350 through 298359):

Bad impact of memory_limit set to -1 ?
        298350 by: Manuel Vacelet

Re: How to take output from an include, and embed it into a variable?
        298351 by: Geert Tapperwijn
        298355 by: Phpster

Web Site Directory Layout
        298352 by: Caner Bulut
        298353 by: Phpster
        298354 by: Caner Bulut
        298356 by: Jim Lucas
        298357 by: Daniel Brown
        298358 by: Daniel Brown
        298359 by: Robert Cummings

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Hi all,

I fighting with SoapServer to be able to upload large file base64 encoded.
Every so often I get memory exhausted error messages and
memory_get_usage() tells me that my script starts with more than 250MB
allocated (for a soap request of 85MB!).

I'm wondering if I would let memory_limit unbound (-1) to avoid those
issues but I don't know what would be the consequences (esp. on
apaches processes, total allocated memory, etc).

Any advice ?
Thanks,
Manuel

--- End Message ---
--- Begin Message ---
Can't you just use the eval <http://nl2.php.net/eval> function, and parse
the code from the include file in it?

.. or is there something I'm missing here?

2009/9/25 Carl Furst <[email protected]>

>
>
> 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:[email protected]]
>>>>> Sent: Wednesday, September 23, 2009 1:36 PM
>>>>> To: [email protected]
>>>>> 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
>
>

--- End Message ---
--- Begin Message ---


On Sep 25, 2009, at 3:12 PM, Geert Tapperwijn <[email protected]> wrote:

Can't you just use the eval <http://nl2.php.net/eval> function, and parse
the code from the include file in it?

.. or is there something I'm missing her


Because eval has risks if code gets injected into the code you mean to run.

Bastien

Sent from my iPod



2009/9/25 Carl Furst <[email protected]>



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:[email protected]]
Sent: Wednesday, September 23, 2009 1:36 PM
To: [email protected]
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



--- End Message ---
--- Begin Message ---
Hi All,

 

Is there a stable or standart directory layout for PHP project (like web
sites)?. 

 

Example;

 

index.php

img/

css/

js/

lib/

doc/

tools/

 

Thanks.

 

 


--- End Message ---
--- Begin Message ---


On Sep 25, 2009, at 6:50 PM, "Caner Bulut" <[email protected]> wrote:

Hi All,



Is there a stable or standart directory layout for PHP project (like web
sites)?.



Example;



index.php

img/

css/

js/

lib/

doc/

tools/



Thanks.


It depends. Using of the many frameworks will force you to userheir layout. If you are coding your own site without one, the you can use whatever you want.

Thanks

Bastien

--- End Message ---
--- Begin Message ---
Thanks Bastien for your advice,

But i still waiting some more advice from experienced developers, maybe this
is related about security and directory permissions?

Thanks.

-----Original Message-----
From: Phpster [mailto:[email protected]] 
Sent: Saturday, September 26, 2009 2:19 AM
To: Caner Bulut
Cc: <[email protected]>; <[email protected]>
Subject: Re: [PHP] Web Site Directory Layout



On Sep 25, 2009, at 6:50 PM, "Caner Bulut" <[email protected]> wrote:

> Hi All,
>
>
>
> Is there a stable or standart directory layout for PHP project (like  
> web
> sites)?.
>
>
>
> Example;
>
>
>
> index.php
>
> img/
>
> css/
>
> js/
>
> lib/
>
> doc/
>
> tools/
>
>
>
> Thanks.


It depends. Using of the many frameworks will force you to userheir  
layout. If you are coding your own site without one, the you can use  
whatever you want.

Thanks

Bastien


--- End Message ---
--- Begin Message ---
Caner Bulut wrote:
> Hi All,
> 
> Is there a stable or standard directory layout for PHP project (like web
> sites)?. 
> 
> Example;
> 
> index.php
> img/
> css/
> js/
> lib/
> doc/
> tools/
> 
> Thanks.
> 

Here are a few references that I found with a quick G search

http://www.shorewalker.com/blog/naming_conventions.html
http://www.haas.ca/Intranet/Naming_Conventions.cfm
http://www.llslim.com/users/slim/blog/2009/directory-structure-and-naming-conventions-web-development
http://lvsonline.com/online-website-class/?page_id=15
http://www.ryerson.ca/cmssupport/standards/Ryerson_guidelines_naming_conventions_version2.0.pdf

--- End Message ---
--- Begin Message ---
On Fri, Sep 25, 2009, Caner Bulut <[email protected]> wrote:
>
> Is there a stable or standart directory layout for PHP project (like web 
> sites)?.

    The very plain, simple answer is: no.  There are similarities
between projects, and common, logical reasons for doing them.... but
nothing that would quite earn the description "standard."  It's what
makes sense to you, and what you think will make sense to future
developers who will inherit your project.

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig

--- End Message ---
--- Begin Message ---
On Fri, Sep 25, 2009 at 19:30, Caner Bulut <[email protected]> wrote:
>
> I will be out of office between 18th - 28th of June.

    That's fantastic.  Have a nice ten-day vacation nine months from
now.  Thanks for letting us know so far in advance!  ;-P

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig

--- End Message ---
--- Begin Message ---
Caner Bulut wrote:
Hi All,

Is there a stable or standart directory layout for PHP project (like web
sites)?.
Example;

index.php
img/
css/
js/
lib/
doc/
tools/

Thanks.

There's no standard. My advice is to use easily identifiable names. The above are quite obbvious. My own preference though is to not shorten names. For instance, I would use the following in place of what you have provided as examples:

index.php
images/
css/
javascript/
lib/
documents/
tools/

That's just personal preference though :)

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---

Reply via email to