php-general Digest 17 Mar 2010 14:30:09 -0000 Issue 6644

Topics (messages 302920 through 302929):

Re: Need routine to tell me number of dimensions in array.
        302920 by: Robert Cummings
        302925 by: Richard Quadling

different php.ini for virtual host on apache2 with mod_php5
        302921 by: Stanislaw V. Smetanin
        302923 by: Rene Veerman
        302924 by: Ashley Sheridan
        302928 by: Shawn McKenzie

Re: best way to set up an include path for a multi-level project?
        302922 by: Robert P. J. Day
        302926 by: Bob McConnell
        302929 by: Robert P. J. Day

natural language processing (nlp) (was: natural text / human text analysis)
        302927 by: Rene Veerman

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---

Rene Veerman wrote:
maybe you should be foreach()ing with references?
php.net : search "foreach" :


As of PHP 5, you can easily modify array's elements by preceding
$value with &. This will assign reference instead of copying the
value.
<?php
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
    $value = $value * 2;
}
// $arr is now array(2, 4, 6, 8)
unset($value); // break the reference with the last element
?>
This is possible only if iterated array can be referenced (i.e. is variable),

References in foreach don't work the way you think they work. You will still incur the copy. At least I did when I tested earlier today :)

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

--- End Message ---
--- Begin Message ---
On 17 March 2010 01:10, Robert Cummings <rob...@interjinn.com> wrote:
>
> Rene Veerman wrote:
>>
>> maybe you should be foreach()ing with references?
>> php.net : search "foreach" :
>>
>>
>> As of PHP 5, you can easily modify array's elements by preceding
>> $value with &. This will assign reference instead of copying the
>> value.
>> <?php
>> $arr = array(1, 2, 3, 4);
>> foreach ($arr as &$value) {
>>    $value = $value * 2;
>> }
>> // $arr is now array(2, 4, 6, 8)
>> unset($value); // break the reference with the last element
>> ?>
>> This is possible only if iterated array can be referenced (i.e. is
>> variable),
>
> References in foreach don't work the way you think they work. You will still
> incur the copy. At least I did when I tested earlier today :)
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

The peak memory usage when using references (or not) and using
foreach() vs array_walk() was the same in all my testing.

But surprisingly, the foreach() with references all round used the
lowest memory during the looping. The worse case was mixing reference
and value passing with array_walk().

My dataset was generated by reading the C:\PHP5 directory where the
keys are the directories and saving the data as an include
(var_export()-ing it).

RIchard.
-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
Hi there.

the problem:
I want to disable mail() function in the one of virtual hosts' that
use PHP(I use mod_php for apache2), and regarding to the
http://www.php.net/manual/en/ini.core.php#ini.disable-functions I
can't use directives like php_value, etc, because value of
disable_functions can be set only in php.ini, but I don't want to
disable mail() on the all of my virtual hosts, just on one.

the question:
Can I use different php.ini for virtual hosts, in my case I want to
use php.ini for one host, where disable_functions = mail will be.

Here backgrounds:
stanis...@smetanin:~$ uname -rv
2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 01:26:53 UTC 2010

stanis...@smetanin:~$ dpkg -l libapache2-mod-php5 | tail -n1
ii  libapache2-mod-php5                  5.2.10.dfsg.1-2ubuntu6.4
             server-side, HTML-embedded scripting language (Apache 2
module)

stanis...@smetanin:~$ apache2 -v
Server version: Apache/2.2.12 (Ubuntu)

Thanks to the community for any help.


-- 
Stanislaw Smetanin. http://stanislaw.su/

--- End Message ---
--- Begin Message ---
i dunno about overriding the entire php function, but you can disable
mail() in the virtualhost section of your apache config with the
following line:

php_value disabled_functions mail

On Wed, Mar 17, 2010 at 9:58 AM, Stanislaw V. Smetanin
<r...@stanislaw.su> wrote:
> Hi there.
>
> the problem:
> I want to disable mail() function in the one of virtual hosts' that
> use PHP(I use mod_php for apache2), and regarding to the
> http://www.php.net/manual/en/ini.core.php#ini.disable-functions I
> can't use directives like php_value, etc, because value of
> disable_functions can be set only in php.ini, but I don't want to
> disable mail() on the all of my virtual hosts, just on one.
>
> the question:
> Can I use different php.ini for virtual hosts, in my case I want to
> use php.ini for one host, where disable_functions = mail will be.
>
> Here backgrounds:
> stanis...@smetanin:~$ uname -rv
> 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 01:26:53 UTC 2010
>
> stanis...@smetanin:~$ dpkg -l libapache2-mod-php5 | tail -n1
> ii  libapache2-mod-php5                  5.2.10.dfsg.1-2ubuntu6.4
>             server-side, HTML-embedded scripting language (Apache 2
> module)
>
> stanis...@smetanin:~$ apache2 -v
> Server version: Apache/2.2.12 (Ubuntu)
>
> Thanks to the community for any help.
>
>
> --
> Stanislaw Smetanin. http://stanislaw.su/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Wed, 2010-03-17 at 12:34 +0200, Rene Veerman wrote:

> i dunno about overriding the entire php function, but you can disable
> mail() in the virtualhost section of your apache config with the
> following line:
> 
> php_value disabled_functions mail
> 
> On Wed, Mar 17, 2010 at 9:58 AM, Stanislaw V. Smetanin
> <r...@stanislaw.su> wrote:
> > Hi there.
> >
> > the problem:
> > I want to disable mail() function in the one of virtual hosts' that
> > use PHP(I use mod_php for apache2), and regarding to the
> > http://www.php.net/manual/en/ini.core.php#ini.disable-functions I
> > can't use directives like php_value, etc, because value of
> > disable_functions can be set only in php.ini, but I don't want to
> > disable mail() on the all of my virtual hosts, just on one.
> >
> > the question:
> > Can I use different php.ini for virtual hosts, in my case I want to
> > use php.ini for one host, where disable_functions = mail will be.
> >
> > Here backgrounds:
> > stanis...@smetanin:~$ uname -rv
> > 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 01:26:53 UTC 2010
> >
> > stanis...@smetanin:~$ dpkg -l libapache2-mod-php5 | tail -n1
> > ii  libapache2-mod-php5                  5.2.10.dfsg.1-2ubuntu6.4
> >             server-side, HTML-embedded scripting language (Apache 2
> > module)
> >
> > stanis...@smetanin:~$ apache2 -v
> > Server version: Apache/2.2.12 (Ubuntu)
> >
> > Thanks to the community for any help.
> >
> >
> > --
> > Stanislaw Smetanin. http://stanislaw.su/
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 


What about disabling mail altogether in favour of a mailer that requires
a login to use? That way, you can easily set quotas and keep track of
all emails sent by each client on your hosting.

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



--- End Message ---
--- Begin Message ---
Stanislaw V. Smetanin wrote:
> Hi there.
> 
> the problem:
> I want to disable mail() function in the one of virtual hosts' that
> use PHP(I use mod_php for apache2), and regarding to the
> http://www.php.net/manual/en/ini.core.php#ini.disable-functions I
> can't use directives like php_value, etc, because value of
> disable_functions can be set only in php.ini, but I don't want to
> disable mail() on the all of my virtual hosts, just on one.
> 
> the question:
> Can I use different php.ini for virtual hosts, in my case I want to
> use php.ini for one host, where disable_functions = mail will be.
> 
> Here backgrounds:
> stanis...@smetanin:~$ uname -rv
> 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 01:26:53 UTC 2010
> 
> stanis...@smetanin:~$ dpkg -l libapache2-mod-php5 | tail -n1
> ii  libapache2-mod-php5                  5.2.10.dfsg.1-2ubuntu6.4
>              server-side, HTML-embedded scripting language (Apache 2
> module)
> 
> stanis...@smetanin:~$ apache2 -v
> Server version: Apache/2.2.12 (Ubuntu)
> 
> Thanks to the community for any help.
> 
> 
<VirtualHost whatever:80>
...
PHPINIDir /var/www/whatever
...
</VirtualHost>

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

--- End Message ---
--- Begin Message ---
On Tue, 16 Mar 2010, John Black wrote:

> On 03/16/2010 06:57 PM, Robert P. J. Day wrote:
> >    i have a project (let's call it "proj") which lives in the "proj"
> > directory and which contains several subdirs, some of which might
> > contain their own subdirs and so on.  some of those subdirs might
> > contain utility classes that i want to include or require elsewhere,
> > so i want to be able to just:
> >    require 'util.php';
> > and have the PHP include path "do the right thing."  right now, it's
> > ugly, as in, having PHP files that do:
> >    require '../../proj/util.php';
> > meaning every single file that wants to include another proj-related
> > file has to know its relative position in the proj hierarchy.   barf.
>
> I used to use auto detecting absolute paths but switched to relative
> paths when a client decided to switch his hosting company, I *think*
> it was GoDaddy. They required relative paths when using the shared
> SSL server or the browser would throw errors.
>
> It is really not bad as long a you keep your directory structure
> consistent. I have never received a bug report because of an include
> path issue. It also does not matter where the root directory of the
> app is located since everything is relative anyway. There is also no
> need for the user to configure anything because of the relative
> paths.
>
> So I just set $include = './include/abc/def/' at the top of the
> executing php page and use it further down. You make $include a
> global or simply pass $include to functions or classes when they
> need to include files. I use the later approach.
>
> As I said I never had a problem with it, it just requires
> consistency.

  i'm not entirely sure what you're suggesting here, but i don't think
it will work for me as one of the things i want to do is set up a
"test" directory, inside which i might have subdirectories with more
test routines, so i can't guarantee *anyone's* position relative to
the top of the "proj" directory.

  i might even want to write PHP scripts and place them quite some
distance from the "proj" directory but still want to include utility
scripts from the "proj" directory.  based on how i've done this with
shell and makefile-based projects in the past, the easiest solution
seemed to be to simply demand that users set a single environment
variable identifying the location of the "proj" directory, and base
everything off of that by extending the include path.  at that point,
everything falls into place and all include/require references work
relative to the top of the "proj" tree.

  i think that's the direction i'm going to go, unless someone has a
compelling reason not to.  thanks.

rday
--

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday
========================================================================

--- End Message ---
--- Begin Message ---
From: Robert P. J. Day

> On Tue, 16 Mar 2010, John Black wrote:
>> On 03/16/2010 06:57 PM, Robert P. J. Day wrote:
>> >    i have a project (let's call it "proj") which lives in the
"proj"
>> > directory and which contains several subdirs, some of which might
>> > contain their own subdirs and so on.  some of those subdirs might
>> > contain utility classes that i want to include or require
elsewhere,
>> > so i want to be able to just:
>> >    require 'util.php';
>> > and have the PHP include path "do the right thing."  right now,
it's
>> > ugly, as in, having PHP files that do:
>> >    require '../../proj/util.php';
>> > meaning every single file that wants to include another
proj-related
>> > file has to know its relative position in the proj hierarchy.
barf.
>>
>> I used to use auto detecting absolute paths but switched to relative
>> paths when a client decided to switch his hosting company, I *think*
>> it was GoDaddy. They required relative paths when using the shared
>> SSL server or the browser would throw errors.
>>
>> It is really not bad as long a you keep your directory structure
>> consistent. I have never received a bug report because of an include
>> path issue. It also does not matter where the root directory of the
>> app is located since everything is relative anyway. There is also no
>> need for the user to configure anything because of the relative
>> paths.
>>
>> So I just set $include = './include/abc/def/' at the top of the
>> executing php page and use it further down. You make $include a
>> global or simply pass $include to functions or classes when they
>> need to include files. I use the later approach.
>>
>> As I said I never had a problem with it, it just requires
>> consistency.
> 
>  i'm not entirely sure what you're suggesting here, but i don't think
> it will work for me as one of the things i want to do is set up a
> "test" directory, inside which i might have subdirectories with more
> test routines, so i can't guarantee *anyone's* position relative to
> the top of the "proj" directory.
> 
>  i might even want to write PHP scripts and place them quite some
> distance from the "proj" directory but still want to include utility
> scripts from the "proj" directory.  based on how i've done this with
> shell and makefile-based projects in the past, the easiest solution
> seemed to be to simply demand that users set a single environment
> variable identifying the location of the "proj" directory, and base
> everything off of that by extending the include path.  at that point,
> everything falls into place and all include/require references work
> relative to the top of the "proj" tree.
> 
>  i think that's the direction i'm going to go, unless someone has a
> compelling reason not to.  thanks.

IOW, you want to point into the first project's test directory from
other projects when you can't know the relative paths between those
projects?

I suspect you will have to manage that on a machine by machine basis,
unless you can convince the entire development team to create a common
directory structure that encompasses all projects.

Bob McConnell

--- End Message ---
--- Begin Message ---
On Wed, 17 Mar 2010, Bob McConnell wrote:

... snip ...

> IOW, you want to point into the first project's test directory from
> other projects when you can't know the relative paths between those
> projects?
>
> I suspect you will have to manage that on a machine by machine
> basis, unless you can convince the entire development team to create
> a common directory structure that encompasses all projects.

  let me emphasize that the layout of the entire "proj" directory will
be consistent across all users and all machines since it will
represent a single SVN checkout, so that's not an issue.  of course,
anyone will be free to check it out anywhere they want but once they
do, its structure will be the same across all checkouts.

  that's why i think the easiest solution is to define a single
environment variable (say, PROJ_DIR) that anyone can set depending on
where they do the checkout, the PHP code itself will (somehow)
initially consult that variable, and all inclusion from then on will
be based on that.  piece of cake, no?

  in fact, developers are free to do more than one checkout, work on
them independently, and change PROJ_DIR depending on which one they
want to pick up for their code.

  does that more clearly explain what i think the right approach is?

rday
--


========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday
========================================================================

--- End Message ---
--- Begin Message ---
I've browsed wikipedia, sf.net and google for code & papers on what is
commonly known as NLP.

I haven't found thesaurus software for native php/mysql, wordnet which
is apparently the leader, provides os-native apps, and "db files"
without db structure and not in any sql format (looks like cvs without
the commas but i'm not sure yet).
When i asked princeton staff about sql releases they simply replied
"we dont do sql here". Which i find a bit strange..
Easiest thing for me to do is write a conversion script that puts
their "db files" in mysql, and work from there.

My search on sf.net turned up empty too, all of the projects with
relevant descriptions have just the name regged, no code releases.

>From reading http://www.go4expert.com/forums/showthread.php?t=35,
"Introduction to Natural Language Processing(NLP)", i gather that NLP
as it is results in much ambiguity on several levels of it's
operation.

It's an interesting problem though, and probably a profitable one, so
i'm going to spend some time trying to come up with something better
from scratch.

On Sun, Mar 14, 2010 at 12:04 AM, Rene Veerman <rene7...@gmail.com> wrote:
> Hi..
>
> I'm building a newsscraper -> portal.
> Fetching, parsing and storing many links to news items per hour was
> not much of a problem.
> Translations between languages can be done via google, so that wont be
> much of a problem either i suspect.
>
> I dont want to reveal too much of my business idea, but i do need to
> do text-analysis, to group related items, and make "suggestions"
> lists.
> I've had a dabble with creating my own ontology structure (kinda like
> a dictionary + thesaurus datamodel) by scraping existing ontology
> websites, but needless to say natural text analysis is a huge field.
> One that i'm a total noob in.
>
> So in the first place, I'm looking for any free/paid useful existing
> data-mining / text-analysis code that can be run easily from php.
> TBH i dont even know my feature-requirements really, i'm interested to
> know what's available.
>
> In the second place, i'm looking for free and published-for-a-cost
> data-mining / text-analysis papers/books that explain how to produce
> useful results.
>
> Thanks for your input.
>

--- End Message ---

Reply via email to