php-general Digest 2 Sep 2008 02:21:21 -0000 Issue 5658
Topics (messages 279217 through 279242):
Re: newbie - how to receive/iterate posted arrays
279217 by: Govinda
Re: how to write good code
279218 by: Shelley
279230 by: Yeti
279238 by: Ross McKay
Google Maps Distance Between UK Postcodes
279219 by: Tom Chubb
279220 by: Colin Guthrie
279221 by: Richard Heyes
279222 by: Tom Chubb
279223 by: Michal Sokolowski
279224 by: mike
279225 by: Colin Guthrie
279226 by: Tom Chubb
Re: skinning a cat (was: Individual bulk e-mails - performance question)
279227 by: Robert Cummings
279231 by: Per Jessen
279234 by: Robert Cummings
Re: Individual bulk e-mails - performance question (was "skinning a cat") :-)
279228 by: Robert Cummings
Re: skinning a cat
279229 by: Robert Cummings
279232 by: Per Jessen
279240 by: Lupus Michaelis
Re: Shared memory, mutex functionality and spawning threads. Is it possible
using PHP?
279233 by: Per Jessen
279236 by: Kent Larsson
279239 by: Eric Butera
279241 by: Al
Re: What's with the Rx symbol?
279235 by: Per Jessen
Re: Job opening in Leiden, Netherlands: PHP/MySQL developer
279237 by: Manuel Lemos
newbie - PHP escaping trigger happy
279242 by: Govinda
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 ---
Thanks Diogo! , and other who replied!
You nailed it ("Of course!" you would say.)
I didn't reply sooner as we had a power out (just enough to get me to
go to bed already ;-)
-G
On Sep 1, 2008, at 2:31 AM, Diogo Neves wrote:
foreach($_POST['$tmbsToiterate'] as $value) {
foreach($_POST['tmbsToiterate'] as $value) {
--- End Message ---
--- Begin Message ---
Hi Shiplu,
For all that you mentioned, and if you want to get a quite good suggestion,
I will highly recommend that you read through McConnell's Code Complete (2nd
Edition).
Specifically:
Chapter 31: Layout and Style
Chapter 32: Self-Documenting Code (Commenting Techniques)
It won't disappoint you.
2008/8/31 Shiplu <[EMAIL PROTECTED]>
> I wanna know how to write good code in php.
> Not oop stuff. I wanna know how to write a good php code file.
> documentation, comments. indentation etc.
> what are the good practices??
>
>
> --
> Blog: http://talk.cmyweb.net/
> Follow me: http://twitter.com/shiplu
>
--
With best regards,
Shelley Shyan
http://phparch.cn
--- End Message ---
--- Begin Message ---
Ross McKay <[EMAIL PROTECTED]> wrote:
> Find out what "bad" is by reading this:
>
> http://thedailywtf.com/Series/CodeSOD.aspx
>
> Then, don't do it like that!
What I enjoyed most on that page was this comment:
> One day, after a code review by one of our 'senior' developers this little
> beauty showed up...
> #define NUMBER_OF_BITS_IN_BYTE 8
> The justification was... that the byte might change.... and no 'magic'
> numbers should appear in the code...
--- End Message ---
--- Begin Message ---
On Mon, 1 Sep 2008 08:50:45 -0700 (PDT), larry wrote:
>Write a lot of code, rewrite code you think is messy (we can always do
>better).
>The more you do the better you should get.
>
>Here is some inspiration on that:
>http://www.codinghorror.com/blog/archives/001160.html
NB: the message of that blog post isn't valid at the most simplistic
level (just write lots of code), and the comments to the post explain
why. Don't just read the guy's blog, read the comments! As an extreme
example, consider the latest repost of a classic at TheDailyWTF:
http://thedailywtf.com/Articles/Classic-WTF-To-the-Hexth-Degree.aspx
5,000+ LOC that misses the point, and can be easily replaced by a
one-line framework call. Clearly, just writing lots of code wasn't this
coder's greatest challenge.
Practice makes perfect, but only if you review your output with an eye
to pick up faults.
On rewriting messy code, I've always approached a bug fix on legacy code
with the view that tidy code breaks less, or at least breaks where you
can see it. More often than not, tidying up some rat's nest of code will
magically fix the problem anyway, and if it doesn't, it can make the bug
very clear to see. This even has a name: refactoring.
I would posit that writing lots of code is good practice, but learning
good from bad comes from reading code. Read your old code (if you can!)
Read other people's code. Read sites that make fun of bad code (great
way to learn what bad code looks like!) Read what makes code good and
what makes it bad. Then write some more code :)
--
Ross McKay, Toronto, NSW Australia
"Before enlightenment: chop wood, carry water;
After enlightenment: chop wood, carry water" - Wu Li
--- End Message ---
--- Begin Message ---
Has anyone tried to work this out?
All I'm trying to get is the rough distance in miles between two UK
postcodes using Google Maps API for a basic auto quote script based on
mileage travelled.
I thought it would be easy but it seems that I need to convert each postcode
to Lat/Long using Geocoding and then work it out from there.
I can't find any examples so before I find another way of 'skinning the cat'
has anyone had experience of this and able to point me the right way?
TIA
--- End Message ---
--- Begin Message ---
Tom Chubb wrote:
I thought it would be easy but it seems that I need to convert each postcode
to Lat/Long using Geocoding and then work it out from there.
That's the best way: then just do something like:
Here's how I do it in SQL, but the principle is the same in PHP, so I'm
sure you'll be able to convert it.
HTHs
Col
<snip>
public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles
= false)
{
$multiplier = 6371;
if ($blnMiles)
$multiplier *= 1.609344;
$rv = <<<ESQL
(ACOS(
SIN(RADIANS($latA)) * SIN(RADIANS($latB))
+ COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) -
RADIANS($lngA)))
* $multiplier)
ESQL;
return $rv;
}
</snip>
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
--- End Message ---
--- Begin Message ---
> Has anyone tried to work this out?
> All I'm trying to get is the rough distance in miles between two UK
> postcodes using Google Maps API for a basic auto quote script based on
> mileage travelled.
> I thought it would be easy but it seems that I need to convert each postcode
> to Lat/Long using Geocoding and then work it out from there.
> I can't find any examples so before I find another way of 'skinning the cat'
> has anyone had experience of this and able to point me the right way?
If it's straight line distance you might well be able to use peter
gorous on the coords. If it's distance by road, then not.
--
Richard Heyes
HTML5 Graphing for IE7, FF, Opera and Safari:
http://www.phpguru.org/RGraph
--- End Message ---
--- Begin Message ---
On 01/09/2008, Colin Guthrie <[EMAIL PROTECTED]> wrote:
>
> Tom Chubb wrote:
>
>> I thought it would be easy but it seems that I need to convert each
>> postcode
>> to Lat/Long using Geocoding and then work it out from there.
>>
>
> That's the best way: then just do something like:
>
> Here's how I do it in SQL, but the principle is the same in PHP, so I'm
> sure you'll be able to convert it.
>
> HTHs
>
> Col
>
> <snip>
> public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles =
> false)
> {
> $multiplier = 6371;
> if ($blnMiles)
> $multiplier *= 1.609344;
>
> $rv = <<<ESQL
> (ACOS(
> SIN(RADIANS($latA)) * SIN(RADIANS($latB))
> + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) -
> RADIANS($lngA)))
> * $multiplier)
> ESQL;
> return $rv;
> }
> </snip>
>
>
>
>
> --
>
> Colin Guthrie
> gmane(at)colin.guthr.ie
> http://colin.guthr.ie/
>
> Day Job:
> Tribalogic Limited [http://www.tribalogic.net/]
> Open Source:
> Mandriva Linux Contributor [http://www.mandriva.com/]
> PulseAudio Hacker [http://www.pulseaudio.org/]
> Trac Hacker [http://trac.edgewall.org/]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Thanks Colin,
That's all way above my head, but I think I'll be able to understand it
after a strong coffee!
Any idea how you get the co-ords from the UK Postcode though?
There seems to be a privacy factor with UK postcodes, but I'm only after the
first section: eg SW11 6**
--- End Message ---
--- Begin Message ---
2008/9/1 Tom Chubb <[EMAIL PROTECTED]>
> On 01/09/2008, Colin Guthrie <[EMAIL PROTECTED]> wrote:
> >
> > Tom Chubb wrote:
> >
> >> I thought it would be easy but it seems that I need to convert each
> >> postcode
> >> to Lat/Long using Geocoding and then work it out from there.
> >>
> >
> > That's the best way: then just do something like:
> >
> > Here's how I do it in SQL, but the principle is the same in PHP, so I'm
> > sure you'll be able to convert it.
> >
> > HTHs
> >
> > Col
> >
> > <snip>
> > public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles =
> > false)
> > {
> > $multiplier = 6371;
> > if ($blnMiles)
> > $multiplier *= 1.609344;
> >
> > $rv = <<<ESQL
> > (ACOS(
> > SIN(RADIANS($latA)) * SIN(RADIANS($latB))
> > + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) -
> > RADIANS($lngA)))
> > * $multiplier)
> > ESQL;
> > return $rv;
> > }
> > </snip>
> >
> >
> >
> >
> > --
> >
> > Colin Guthrie
> > gmane(at)colin.guthr.ie
> > http://colin.guthr.ie/
> >
> > Day Job:
> > Tribalogic Limited [http://www.tribalogic.net/]
> > Open Source:
> > Mandriva Linux Contributor [http://www.mandriva.com/]
> > PulseAudio Hacker [http://www.pulseaudio.org/]
> > Trac Hacker [http://trac.edgewall.org/]
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> Thanks Colin,
> That's all way above my head, but I think I'll be able to understand it
> after a strong coffee!
> Any idea how you get the co-ords from the UK Postcode though?
> There seems to be a privacy factor with UK postcodes, but I'm only after
> the
> first section: eg SW11 6**
>
This address should help you. Thay have distance calculator on the page but
also you can download database with postcodes and their co-ords ->
http://www.pc-i.co.uk/postcode-distance.php
--- End Message ---
--- Begin Message ---
This is what I have:
$distance = number_format(ceil(69*rad2deg(acos(sin(deg2rad($ulat)) *
sin(deg2rad($vlat)) + cos(deg2rad($ulat)) * cos(deg2rad($vlat)) *
cos(deg2rad($ulong - $vlong))))));
where:
$ulat = latitude of user #1
$ulong = longitude of user #1
$vlat = latitude of user #2
$vlong = longitude of user #2
it seems to work properly at least with US data. I assume any
longitude/latitude date will work fine with it. If anyone has links to
other countries' zipcode mappings I'd love to be able to add that to
my site :)
(I basically took a MySQL query and mapped it to the PHP functions)
On 9/1/08, Tom Chubb <[EMAIL PROTECTED]> wrote:
> > <snip>
> > public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles =
> > false)
> > {
> > $multiplier = 6371;
> > if ($blnMiles)
> > $multiplier *= 1.609344;
> >
> > $rv = <<<ESQL
> > (ACOS(
> > SIN(RADIANS($latA)) * SIN(RADIANS($latB))
> > + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) -
> > RADIANS($lngA)))
> > * $multiplier)
> > ESQL;
> > return $rv;
> > }
--- End Message ---
--- Begin Message ---
Tom Chubb wrote:
That's all way above my head, but I think I'll be able to understand it
after a strong coffee!
I should point out that this is really just trig and is only an
approximate distance as the crow flies. Not even sure if it takes the
curvature of the earth into consideration, but it's probably "good
enough" for most things.
Any idea how you get the co-ords from the UK Postcode though?
Well that's tricky. It depends on how google do it's geodata service
now. In the past they did not offer a postcode lookup service for the
UK, but I've not looked for a while and this may now be possible.
When I had to solve this problem a few years ago we bought in a database
of UK postcodes. IIRC it's about £1k/annum via Bartholomew but there are
plenty people offering this now.
Col.
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
--- End Message ---
--- Begin Message ---
On 01/09/2008, Michal Sokolowski <[EMAIL PROTECTED]> wrote:
>
>
>
> 2008/9/1 Tom Chubb <[EMAIL PROTECTED]>
>
>> On 01/09/2008, Colin Guthrie <[EMAIL PROTECTED]> wrote:
>> >
>> > Tom Chubb wrote:
>> >
>> >> I thought it would be easy but it seems that I need to convert each
>> >> postcode
>> >> to Lat/Long using Geocoding and then work it out from there.
>> >>
>> >
>> > That's the best way: then just do something like:
>> >
>> > Here's how I do it in SQL, but the principle is the same in PHP, so I'm
>> > sure you'll be able to convert it.
>> >
>> > HTHs
>> >
>> > Col
>> >
>> > <snip>
>> > public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles =
>> > false)
>> > {
>> > $multiplier = 6371;
>> > if ($blnMiles)
>> > $multiplier *= 1.609344;
>> >
>> > $rv = <<<ESQL
>> > (ACOS(
>> > SIN(RADIANS($latA)) * SIN(RADIANS($latB))
>> > + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) -
>> > RADIANS($lngA)))
>> > * $multiplier)
>> > ESQL;
>> > return $rv;
>> > }
>> > </snip>
>> >
>> >
>> >
>> >
>> > --
>> >
>> > Colin Guthrie
>> > gmane(at)colin.guthr.ie
>> > http://colin.guthr.ie/
>> >
>> > Day Job:
>> > Tribalogic Limited [http://www.tribalogic.net/]
>> > Open Source:
>> > Mandriva Linux Contributor [http://www.mandriva.com/]
>> > PulseAudio Hacker [http://www.pulseaudio.org/]
>> > Trac Hacker [http://trac.edgewall.org/]
>> >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>>
>> Thanks Colin,
>> That's all way above my head, but I think I'll be able to understand it
>> after a strong coffee!
>> Any idea how you get the co-ords from the UK Postcode though?
>> There seems to be a privacy factor with UK postcodes, but I'm only after
>> the
>> first section: eg SW11 6**
>>
>
>
> This address should help you. Thay have distance calculator on the page but
> also you can download database with postcodes and their co-ords ->
> http://www.pc-i.co.uk/postcode-distance.php
>
>
That's perfect for what I need! Thanks very much Michal
Tom
--- End Message ---
--- Begin Message ---
On Mon, 2008-09-01 at 09:44 +0200, Per Jessen wrote:
> Robert Cummings wrote:
>
> >> >> #!/bin/sh
> >> >> while true
> >> >> do
> >> >> <yourscript>
> >> >> sleep 300
> >> >> done
> >> >
> >> > I accomplish the same with cron scripts by using locks with expiry.
> >>
> >> got an example? my cat skinning skills need to be improved, the cat
> >> won't like it but screw the cat, right?
> >
> [snip code]
> > I implemented my own lock class which uses directory creation and the
> > return value to determine if the lock was successful. Unlike file
> > creation (or so I read several years ago) directory creation is atomic
> > and works across NFS. As an added benefit, I'm able to store lock
> > related data into the lock directory as files.
>
> I'm probably old fashioned, but to me all that stuff is way overkill. I
> also tend to think that synchronizing scripts is a job for the shell,
> not PHP.
>
> lockfile=/var/lock/<xxxx>/file
> # clear out a lock older than 60mins
> find $lockfile -cmin +60 | xargs rm
> test ! -f $lockfile && (
> touch $lockfile
> <run some php>
> rm -f $lockfile
> )
Try running that on windows.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
>> I'm probably old fashioned, but to me all that stuff is way overkill.
>> I also tend to think that synchronizing scripts is a job for the
>> shell, not PHP.
>>
>> lockfile=/var/lock/<xxxx>/file
>> # clear out a lock older than 60mins
>> find $lockfile -cmin +60 | xargs rm
>> test ! -f $lockfile && (
>> touch $lockfile
>> <run some php>
>> rm -f $lockfile
>> )
>
> Try running that on windows.
Why? - we don't use Windows.
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
On Mon, 2008-09-01 at 20:22 +0200, Per Jessen wrote:
> Robert Cummings wrote:
>
> >> I'm probably old fashioned, but to me all that stuff is way overkill.
> >> I also tend to think that synchronizing scripts is a job for the
> >> shell, not PHP.
> >>
> >> lockfile=/var/lock/<xxxx>/file
> >> # clear out a lock older than 60mins
> >> find $lockfile -cmin +60 | xargs rm
> >> test ! -f $lockfile && (
> >> touch $lockfile
> >> <run some php>
> >> rm -f $lockfile
> >> )
> >
> > Try running that on windows.
>
> Why? - we don't use Windows.
I get requests from time to time to do windows work. My scripts just
happen to work in windows or linux. I guess that's because I don't punt
to shell scripts what is easily implemented in PHP ;)
99% of what I do is linux based. But knowing what to do for the other 1%
is pure gold to my clients.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
On Mon, 2008-09-01 at 14:34 +0200, Merlin Morgenstern wrote:
> Per Jessen schrieb:
> > Jochem Maas wrote:
> >
> >>> lockfile=/var/lock/<xxxx>/file
> >>> # clear out a lock older than 60mins
> >>> find $lockfile -cmin +60 | xargs rm
> >>> test ! -f $lockfile && (
> >>> touch $lockfile
> >>> <run some php>
> >>> rm -f $lockfile
> >>> )
> >> wouldn't creating a dir be better here? (with regard to atomicity)
> >>
> >
> > I haven't thought it through, but I don't think it would change
> > anything.
> >
> >
> > /Per Jessen, Zürich
> >
>
> Hello everybody,
>
> thank you for the huge amount of replies on my question. I believe I
> quite lost a bit track on how to solve the problem hands on. To
> summerize, there are aparently two ways of skinning the cat :-)
>
> 1. Run a deamon
> I admit I have never wrote one, and that seems therefore to be the
> harder option for me. Well... perhaps not.
> I assume it is simply creating a shell script like Jochem wrote, however
> I guess it would just take longer for me to get it running as I have
> never done that before.
>
> 2. Create a PHP file that holds some lock code which is triggered by
> CRON every 5 minutes. Taking the example from Robert.
>
> 3. Following idea which I am now actually implementing :-)
>
> - Add all emails into a mysql db with one insert command.
> - Run a php script by cron every 5 min that does the following:
> - update table, set session_id = x on all entries without session id
> - get all entries with that session ID
> - send email to those with that session ID
> - remove all entries with that session ID
>
> Looks like easies sollution on how to skimm the cat. DB might not be the
> most performing sollution, but sufficient considering the hard ware power.
Actually 3 was what I suggested with a lock mechanism to ensure that if
your script run by cron takes longer than 5 minutes that you don't have
two scritps stepping on each others' toes.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
On Mon, 2008-09-01 at 14:51 +0200, Per Jessen wrote:
> Jochem Maas wrote:
>
> > Per Jessen schreef:
> >> Jochem Maas wrote:
> >>
> >>>> lockfile=/var/lock/<xxxx>/file
> >>>> # clear out a lock older than 60mins
> >>>> find $lockfile -cmin +60 | xargs rm
> >>>> test ! -f $lockfile && (
> >>>> touch $lockfile
> >>>> <run some php>
> >>>> rm -f $lockfile
> >>>> )
> >>> wouldn't creating a dir be better here? (with regard to atomicity)
> >>>
> >>
> >> I haven't thought it through, but I don't think it would change
> >> anything.
> >
> > directory creation is garanteed to be atomic, even across NFS, or
> > so Rob said.
>
> Maybe so, but to avoid a race-condition, you need the test+touch
> sequence to be atomic.
The return value of creating the directory is either true for it having
been made or false for it having not been made. Therein lies the
atomicity. The OS will not return success if it was not made and will
not return failure if it was made.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
> The return value of creating the directory is either true for it
> having been made or false for it having not been made. Therein lies
> the atomicity. The OS will not return success if it was not made and
> will not return failure if it was made.
Ah, interesting. Thanks.
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
Robert Cummings a écrit :
Try running that on windows.
No problem
<http://technet.microsoft.com/en-us/interopmigration/bb380242.aspx>
--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org
--- End Message ---
--- Begin Message ---
Kent Larsson wrote:
> Hi,
>
> Is it possible to have shared memory in the form of shared global
> variables in PHP? Or any other form of shared memory? And if that is
> the case, is there any form of mutex functionality which may be used
> to assure syncronized access to this memory?
>
> My next question is related to the first one.
I can't answer any of your questions, but if you need shared memory,
mutexes and threading, I would advice against using PHP.
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
Hi,
Thank you for your answer. I was hoping there were a solution. :-/ It would
have been nice as PHP has a large install base and is a quite common element
in cheap web hosting solutions. Has anyone else got any more comments or
suggestions?
In absence of shared memory and threads. What I really must have is some
kind of mutex functionality. I will be manipulating files on disk and I
don't want two instances to be able to touch the disk at the same time. Is
there something I could use for mutual exclusion? If there aren't any
dedicated methods, are there 100% reliable workarounds?
On Mon, Sep 1, 2008 at 8:27 PM, Per Jessen <[EMAIL PROTECTED]> wrote:
> Kent Larsson wrote:
>
> > Hi,
> >
> > Is it possible to have shared memory in the form of shared global
> > variables in PHP? Or any other form of shared memory? And if that is
> > the case, is there any form of mutex functionality which may be used
> > to assure syncronized access to this memory?
> >
> > My next question is related to the first one.
>
> I can't answer any of your questions, but if you need shared memory,
> mutexes and threading, I would advice against using PHP.
>
>
> /Per Jessen, Zürich
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Mon, Sep 1, 2008 at 5:45 PM, Kent Larsson <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Thank you for your answer. I was hoping there were a solution. :-/ It would
> have been nice as PHP has a large install base and is a quite common element
> in cheap web hosting solutions. Has anyone else got any more comments or
> suggestions?
>
> In absence of shared memory and threads. What I really must have is some
> kind of mutex functionality. I will be manipulating files on disk and I
> don't want two instances to be able to touch the disk at the same time. Is
> there something I could use for mutual exclusion? If there aren't any
> dedicated methods, are there 100% reliable workarounds?
>
> On Mon, Sep 1, 2008 at 8:27 PM, Per Jessen <[EMAIL PROTECTED]> wrote:
>
>> Kent Larsson wrote:
>>
>> > Hi,
>> >
>> > Is it possible to have shared memory in the form of shared global
>> > variables in PHP? Or any other form of shared memory? And if that is
>> > the case, is there any form of mutex functionality which may be used
>> > to assure syncronized access to this memory?
>> >
>> > My next question is related to the first one.
>>
>> I can't answer any of your questions, but if you need shared memory,
>> mutexes and threading, I would advice against using PHP.
>>
>>
>> /Per Jessen, Zürich
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
Perhaps these may be of interest:
http://us.php.net/manual/en/ref.shmop.php
http://us3.php.net/pcntl_fork
http://us3.php.net/manual/en/book.sem.php
--- End Message ---
--- Begin Message ---
Kent Larsson wrote:
Hi,
Is it possible to have shared memory in the form of shared global variables
in PHP? Or any other form of shared memory? And if that is the case, is
there any form of mutex functionality which may be used to assure
syncronized access to this memory?
My next question is related to the first one.
Is it possible to have a thread running for processing of information. This
thread should be accessed from all the session instances, and it would also
need to be syncronized. I would like to have something like:
jobProcessorThread.addJob(aJobClassInstance)
The job processor thread should work with the jobs in its queue until the
queue is empty. Then it should idle until more requests are received.
And my last question.
Is it possible to let any code run and perform its work after PHP has sent
the page to the user? This could be an alternative to having a worker thread
in if it's also possible to have mutexes and shared memory. Then the worker
thread jobs could be processed after a page has been sent inside a critical
block protected by mutex functionality.
Best regards,
Kent
You may find the PEAR Cache_Lite::Cache_Lite() helpful. It has memory caching,
etc.
--- End Message ---
--- Begin Message ---
Robin Vickery wrote:
> Firefox holds a whitelist of toplevel domains that are allowed to
> display unicode (to see the list go to about:config and enter
> IDN.whitelist into the filter box).
>
> It does not allow .com domains to contain unicode for obvious phishing
> reasons,
Very interesting, I had no idea.
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
Hello,
on 09/01/2008 09:15 AM Ivo F.A.C. Fokkema said the following:
Dear all,
We have an immediate job opening available to work in our team of
bio-informaticians on extending the LOVD software (www.LOVD.nl). Even if
you're still a beginner with PHP you're welcome to respond. Affinity to
biology is a big plus.
LOVD (Leiden Open Variation Database) is webbased software used by
hospitals and clinics worldwide to store patient and DNA mutation
information.
For more information, see our website or these two PDF files:
http://www.lovd.nl/Vac08_G2P_LSDBs.pdf
http://www.lovd.nl/LUMC_E.08.GJ.16HG.pdf
If you're interested, please let me know as soon as possible since we've
already started selecting candidates.
You may want to try posting it here:
http://www.phpclasses.org/jobs/
Also here you will find many qualified PHP professionals from The
Netherlands:
http://www.phpclasses.org/professionals/country/nl/
--
Regards,
Manuel Lemos
Find and post PHP jobs
http://www.phpclasses.org/jobs/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
Just a quick Q, which I know has to be in the docs somewhere, but I
haven't come across it yet-
PHP automatically escaping single and double quotes... how to turn it
off?
I.e.-
in a form text input, someone inputs
love's "influence" <grows>
and on the posted page I get:
love\'s \"influence\"
WHen I wrap that with htmlspecialchars , then I get:
love\'s \"influence\" <grows>
What I want is:
love's "influence" <grows>
...in this case anyway. Probably if I understood why PHP was escaping
the quotes, then I likely would want that behavior in those
circumstances it was designed for... but not now, and I don't know
how to turn it off.
Thanks,
-Govinda
--- End Message ---