php-general Digest 3 May 2011 09:17:56 -0000 Issue 7295

Topics (messages 312636 through 312652):

Re: semaphore release before acquire warning
        312636 by: Nathan Nobbe
        312637 by: Jeremy Greene

Custom function
        312638 by: Ron Piggott
        312639 by: Richard S. Crawford
        312640 by: Ron Piggott
        312641 by: Ashley Sheridan
        312651 by: Andre Polykanine
        312652 by: Ashley Sheridan

php to store data
        312642 by: sir wally lewis
        312643 by: Ashley Sheridan
        312644 by: sir wally lewis
        312645 by: admin.buskirkgraphics.com
        312646 by: admin.buskirkgraphics.com
        312647 by: Ashley Sheridan
        312648 by: Bastien
        312649 by: Ashley Sheridan
        312650 by: Tamara Temple

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 ---
On Mon, May 2, 2011 at 2:57 PM, Jeremy Greene <[email protected]> wrote:

> Hi,
>
>
>
> I am getting a warning when calling sem_release() before (the same php
> script) calls sem_acquire(). I am doing this because it's a "signal" to
> another process. The other process (which happens to be C program) has
> done, or will do, a semop() to acquire the semaphore/signal. The actual
> data transfer is through shared memory.
>
>
>
> It does all functionally work quite nicely, but given that I'm getting
> the warning and that there doesn't seem to be any discussion of this at
> least in this list's archive maybe I'm putting a square peg into a round
> hole... or at least there's a rounder peg available.
>
>
>
> I did look into disabling the warning, but that got me more concerned
> since it seemed like a frowned upon thing to do and even more of a
> performance hit.
>
>
>
> The irony is that I'm using shared memory (and signals) exactly for
> performance reasons L


perhaps try pcntl_signal() to signal the c program rather than
sem_release().

-nathan

--- End Message ---
--- Begin Message ---
I have had really bad luck with signals. They can be “lost” in more than one 
way.

I thought this was the far more reliable and correct way… at least from that 
point of view.

 

Jeremy

 

From: Nathan Nobbe [mailto:[email protected]] 
Sent: Monday, May 02, 2011 5:01 PM
To: Jeremy Greene
Cc: [email protected]
Subject: Re: [PHP] semaphore release before acquire warning

 

On Mon, May 2, 2011 at 2:57 PM, Jeremy Greene <[email protected]> wrote:

        Hi,
        
        
        
        I am getting a warning when calling sem_release() before (the same php
        script) calls sem_acquire(). I am doing this because it's a "signal" to
        another process. The other process (which happens to be C program) has
        done, or will do, a semop() to acquire the semaphore/signal. The actual
        data transfer is through shared memory.
        
        
        
        It does all functionally work quite nicely, but given that I'm getting
        the warning and that there doesn't seem to be any discussion of this at
        least in this list's archive maybe I'm putting a square peg into a round
        hole... or at least there's a rounder peg available.
        
        
        
        I did look into disabling the warning, but that got me more concerned
        since it seemed like a frowned upon thing to do and even more of a
        performance hit.
        
        
        
        The irony is that I'm using shared memory (and signals) exactly for
        performance reasons L

 

perhaps try pcntl_signal() to signal the c program rather than sem_release().

 

-nathan


--- End Message ---
--- Begin Message ---
Is it possible to write a function with an optional flag?  What would the 
syntax look like? 

So far I have:

function load_advertisement( $web_page_reference , 
$web_advertising_sizes_reference ) {

Thanks Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info  

--- End Message ---
--- Begin Message ---
On Mon, May 2, 2011 at 3:16 PM, Ron Piggott
<[email protected]>wrote:

>
> Is it possible to write a function with an optional flag?  What would the
> syntax look like?
>
> So far I have:
>
> function load_advertisement( $web_page_reference ,
> $web_advertising_sizes_reference ) {
>


Hi Ron:

I'm not sure what you mean by "optional flag"? Do you mean an optional
parameter?

Richard

-- 
Sláinte,
Richard S. Crawford ([email protected])
http://www.underpope.com
Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)

--- End Message ---
--- Begin Message ---
On Mon, May 2, 2011 at 3:16 PM, Ron Piggott <[email protected]> 
wrote:


  Is it possible to write a function with an optional flag?  What would the 
syntax look like?

  So far I have:

  function load_advertisement( $web_page_reference , 
$web_advertising_sizes_reference ) {



Hi Ron:

I'm not sure what you mean by "optional flag"? Do you mean an optional 
parameter?

Richard 


Correct Richard.  Ron

--- End Message ---
--- Begin Message ---
On Mon, 2011-05-02 at 18:28 -0400, Ron Piggott wrote:

> On Mon, May 2, 2011 at 3:16 PM, Ron Piggott <[email protected]> 
> wrote:
> 
> 
>   Is it possible to write a function with an optional flag?  What would the 
> syntax look like?
> 
>   So far I have:
> 
>   function load_advertisement( $web_page_reference , 
> $web_advertising_sizes_reference ) {
> 
> 
> 
> Hi Ron:
> 
> I'm not sure what you mean by "optional flag"? Do you mean an optional 
> parameter?
> 
> Richard 
> 
> 
> Correct Richard.  Ron


function load_advertisement( $web_page_reference ,
$web_advertising_sizes_reference=default_value)

This sets a default value for a parameter, which you can check for
within the function itself and use it if it differs from what you set.
Set it to something that it shouldn't be, like null or something.

Also note that these parameters have to occur after any that don't have
a default value

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



--- End Message ---
--- Begin Message ---
Hello Ashley,

By  the  way,  the  non-last  optional parameter can't be missed, am I
right? In some languages we could write something like:
function test ($a, $foo=50, $bar=true) {
// ...
}

Then call it like this:

$m=test("blah", , false);

meaning

$m=test("blah", 50, false);
This is impossible in PHP, isn't it?
Thanks!

-- 
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

------------ Original message ------------
From: Ashley Sheridan <[email protected]>
To: Ron Piggott
Date created: , 1:37:59 AM
Subject: [PHP] Custom function


      On Mon, 2011-05-02 at 18:28 -0400, Ron Piggott wrote:

> On Mon, May 2, 2011 at 3:16 PM, Ron Piggott <[email protected]> 
> wrote:
> 
> 
>   Is it possible to write a function with an optional flag?  What would the 
> syntax look like?
> 
>   So far I have:
> 
>   function load_advertisement( $web_page_reference , 
> $web_advertising_sizes_reference ) {
> 
> 
> 
> Hi Ron:
> 
> I'm not sure what you mean by "optional flag"? Do you mean an optional 
> parameter?
> 
> Richard 
> 
> 
> Correct Richard.  Ron


function load_advertisement( $web_page_reference ,
$web_advertising_sizes_reference=default_value)

This sets a default value for a parameter, which you can check for
within the function itself and use it if it differs from what you set.
Set it to something that it shouldn't be, like null or something.

Also note that these parameters have to occur after any that don't have
a default value

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



--- End Message ---
--- Begin Message ---
"Andre Polykanine" <[email protected]> wrote:

>Hello Ashley,
>
>By  the  way,  the  non-last  optional parameter can't be missed, am I
>right? In some languages we could write something like:
>function test ($a, $foo=50, $bar=true) {
>// ...
>}
>
>Then call it like this:
>
>$m=test("blah", , false);
>
>meaning
>
>$m=test("blah", 50, false);
>This is impossible in PHP, isn't it?
>Thanks!
>
>--
>With best regards from Ukraine,
>Andre
>Skype: Francophile
>My blog: http://oire.org/menelion (mostly in Russian)
>Twitter: http://twitter.com/m_elensule
>Facebook: http://facebook.com/menelion
>
>------------ Original message ------------
>From: Ashley Sheridan <[email protected]>
>To: Ron Piggott
>Date created: , 1:37:59 AM
>Subject: [PHP] Custom function
>
>
>      On Mon, 2011-05-02 at 18:28 -0400, Ron Piggott wrote:
>
>> On Mon, May 2, 2011 at 3:16 PM, Ron Piggott
><[email protected]> wrote:
>>
>>
>>   Is it possible to write a function with an optional flag?  What
>would the syntax look like?
>>
>>   So far I have:
>>
>>   function load_advertisement( $web_page_reference ,
>$web_advertising_sizes_reference ) {
>>
>>
>>
>> Hi Ron:
>>
>> I'm not sure what you mean by "optional flag"? Do you mean an
>optional parameter?
>>
>> Richard
>>
>>
>> Correct Richard.  Ron
>
>
>function load_advertisement( $web_page_reference ,
>$web_advertising_sizes_reference=default_value)
>
>This sets a default value for a parameter, which you can check for
>within the function itself and use it if it differs from what you set.
>Set it to something that it shouldn't be, like null or something.
>
>Also note that these parameters have to occur after any that don't have
>a default value
>
>--
>Thanks,
>Ash
>http://www.ashleysheridan.co.uk
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

Yes, it behaves like any built-in php function in that respect, you can't omit 
a parameter mid-way in a param list. However, you can give it a dummy value 
that you can look for and ignore in your code, but it gets a little more 
complex then.

I did forget to mention that a function also has a special func_get_args() 
method that can be used to access parameters sent to the function that weren't 
in the function declaration.


Thanks
Ash
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--- End Message ---
--- Begin Message ---
I am a complete novice at php.
My internet service provider gives me webspace and PHP script execution for free.

I would like a simple example of a website that stores data on the server, in simple text files.

Is this possible?

Kind Regards,

Robert

--- End Message ---
--- Begin Message ---
On Mon, 2011-05-02 at 17:55 +1000, sir wally lewis wrote:

> I am a complete novice at php.
> My internet service provider gives me webspace and PHP script execution 
> for free.
> 
> I would like a simple example of a website that stores data on the 
> server, in simple text files.
> 
> Is this possible?
> 
> Kind Regards,
> 
> Robert
> 


If you're storing data, try to use a database, as you can do a lot more
with a DB than you can with flat text files on the server, and it's much
faster.

However, if you're stuck with text files, then look at things like
fopen, fwrite and file_get_contents functions, as these should help a
lot.

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



--- End Message ---
--- Begin Message ---
I did not get access to any database system on the ISP's end.
I could get access to MySQL for $$$.
Initially I just want to test everything works with storing to simple text 
files.
After that has happenned.
And if the requirement grows.
Then spending $$$ is feasable.

As I said I am just a novice.
So I want to get something small going.

Kind Regards,

Robert.


"Ashley Sheridan" <[email protected]> wrote in message 
news:[email protected]...
> On Mon, 2011-05-02 at 17:55 +1000, sir wally lewis wrote:
>
>> I am a complete novice at php.
>> My internet service provider gives me webspace and PHP script execution
>> for free.
>>
>> I would like a simple example of a website that stores data on the
>> server, in simple text files.
>>
>> Is this possible?
>>
>> Kind Regards,
>>
>> Robert
>>
>
>
> If you're storing data, try to use a database, as you can do a lot more
> with a DB than you can with flat text files on the server, and it's much
> faster.
>
> However, if you're stuck with text files, then look at things like
> fopen, fwrite and file_get_contents functions, as these should help a
> lot.
>
> -- 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
> 



--- End Message ---
--- Begin Message ---
Do your provider offer MySQL or MSSQL?

Richard L. Buskirk



-----Original Message-----
From: sir wally lewis [mailto:[email protected]] 
Sent: Monday, May 02, 2011 3:56 AM
To: [email protected]
Subject: [PHP] php to store data

I am a complete novice at php.
My internet service provider gives me webspace and PHP script execution 
for free.

I would like a simple example of a website that stores data on the 
server, in simple text files.

Is this possible?

Kind Regards,

Robert

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


--- End Message ---
--- Begin Message ---
Sorry just seen posting and thought it was new.
Most hosting sites offer MySQL with PHP



Richard L. Buskirk


-----Original Message-----
From: sir wally lewis [mailto:[email protected]] 
Sent: Monday, May 02, 2011 3:56 AM
To: [email protected]
Subject: [PHP] php to store data

I am a complete novice at php.
My internet service provider gives me webspace and PHP script execution 
for free.

I would like a simple example of a website that stores data on the 
server, in simple text files.

Is this possible?

Kind Regards,

Robert

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


--- End Message ---
--- Begin Message ---
On Tue, 2011-05-03 at 09:36 +1000, Sir Wally Lewis wrote:

> I did not get access to any database system on the ISP's end.
> I could get access to MySQL for $$$.
> Initially I just want to test everything works with storing to simple text 
> files.
> After that has happenned.
> And if the requirement grows.
> Then spending $$$ is feasable.
> 
> As I said I am just a novice.
> So I want to get something small going.
> 
> Kind Regards,
> 
> Robert.
> 
> 
> "Ashley Sheridan" <[email protected]> wrote in message 
> news:[email protected]...
> > On Mon, 2011-05-02 at 17:55 +1000, sir wally lewis wrote:
> >
> >> I am a complete novice at php.
> >> My internet service provider gives me webspace and PHP script execution
> >> for free.
> >>
> >> I would like a simple example of a website that stores data on the
> >> server, in simple text files.
> >>
> >> Is this possible?
> >>
> >> Kind Regards,
> >>
> >> Robert
> >>
> >
> >
> > If you're storing data, try to use a database, as you can do a lot more
> > with a DB than you can with flat text files on the server, and it's much
> > faster.
> >
> > However, if you're stuck with text files, then look at things like
> > fopen, fwrite and file_get_contents functions, as these should help a
> > lot.
> >
> > -- 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> > 
> 
> 
> 


Look into the functions I mentioned, they have enough examples on the
php.net man pages to get you to a point where you can put some code
together to do what you need.

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



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

On 2011-05-02, at 8:21 PM, Ashley Sheridan <[email protected]> wrote:

> On Tue, 2011-05-03 at 09:36 +1000, Sir Wally Lewis wrote:
> 
>> I did not get access to any database system on the ISP's end.
>> I could get access to MySQL for $$$.
>> Initially I just want to test everything works with storing to simple text 
>> files.
>> After that has happenned.
>> And if the requirement grows.
>> Then spending $$$ is feasable.
>> 
>> As I said I am just a novice.
>> So I want to get something small going.
>> 
>> Kind Regards,
>> 
>> Robert.
>> 
>> 
>> "Ashley Sheridan" <[email protected]> wrote in message 
>> news:[email protected]...
>>> On Mon, 2011-05-02 at 17:55 +1000, sir wally lewis wrote:
>>> 
>>>> I am a complete novice at php.
>>>> My internet service provider gives me webspace and PHP script execution
>>>> for free.
>>>> 
>>>> I would like a simple example of a website that stores data on the
>>>> server, in simple text files.
>>>> 
>>>> Is this possible?
>>>> 
>>>> Kind Regards,
>>>> 
>>>> Robert
>>>> 
>>> 
>>> 
>>> If you're storing data, try to use a database, as you can do a lot more
>>> with a DB than you can with flat text files on the server, and it's much
>>> faster.
>>> 
>>> However, if you're stuck with text files, then look at things like
>>> fopen, fwrite and file_get_contents functions, as these should help a
>>> lot.
>>> 
>>> -- 
>>> Thanks,
>>> Ash
>>> http://www.ashleysheridan.co.uk
>>> 
>>> 
>>> 
>> 
>> 
>> 
> 
> 
> Look into the functions I mentioned, they have enough examples on the
> php.net man pages to get you to a point where you can put some code
> together to do what you need.
> 
> -- 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 

You might want to google flat file databases. There are systems that already do 
this.

Bastien Koert


--- End Message ---
--- Begin Message ---
On Mon, 2011-05-02 at 20:35 -0400, Bastien wrote:

> 
> On 2011-05-02, at 8:21 PM, Ashley Sheridan <[email protected]> wrote:
> 
> > On Tue, 2011-05-03 at 09:36 +1000, Sir Wally Lewis wrote:
> > 
> >> I did not get access to any database system on the ISP's end.
> >> I could get access to MySQL for $$$.
> >> Initially I just want to test everything works with storing to simple text 
> >> files.
> >> After that has happenned.
> >> And if the requirement grows.
> >> Then spending $$$ is feasable.
> >> 
> >> As I said I am just a novice.
> >> So I want to get something small going.
> >> 
> >> Kind Regards,
> >> 
> >> Robert.
> >> 
> >> 
> >> "Ashley Sheridan" <[email protected]> wrote in message 
> >> news:[email protected]...
> >>> On Mon, 2011-05-02 at 17:55 +1000, sir wally lewis wrote:
> >>> 
> >>>> I am a complete novice at php.
> >>>> My internet service provider gives me webspace and PHP script execution
> >>>> for free.
> >>>> 
> >>>> I would like a simple example of a website that stores data on the
> >>>> server, in simple text files.
> >>>> 
> >>>> Is this possible?
> >>>> 
> >>>> Kind Regards,
> >>>> 
> >>>> Robert
> >>>> 
> >>> 
> >>> 
> >>> If you're storing data, try to use a database, as you can do a lot more
> >>> with a DB than you can with flat text files on the server, and it's much
> >>> faster.
> >>> 
> >>> However, if you're stuck with text files, then look at things like
> >>> fopen, fwrite and file_get_contents functions, as these should help a
> >>> lot.
> >>> 
> >>> -- 
> >>> Thanks,
> >>> Ash
> >>> http://www.ashleysheridan.co.uk
> >>> 
> >>> 
> >>> 
> >> 
> >> 
> >> 
> > 
> > 
> > Look into the functions I mentioned, they have enough examples on the
> > php.net man pages to get you to a point where you can put some code
> > together to do what you need.
> > 
> > -- 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> > 
> 
> You might want to google flat file databases. There are systems that already 
> do this.
> 
> Bastien Koert
> 


He didn't say he necessarily wanted database-like functionality, just
that he wanted to be able to store data in text files. This could be
something as simple as a log, or basic CMS that generates the HTML pages
that make up a website.

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



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

On May 2, 2011, at 8:14 PM, Ashley Sheridan wrote:

On Mon, 2011-05-02 at 20:35 -0400, Bastien wrote:


On 2011-05-02, at 8:21 PM, Ashley Sheridan <[email protected]> wrote:

On Tue, 2011-05-03 at 09:36 +1000, Sir Wally Lewis wrote:

I did not get access to any database system on the ISP's end.
I could get access to MySQL for $$$.
Initially I just want to test everything works with storing to simple text
files.
After that has happenned.
And if the requirement grows.
Then spending $$$ is feasable.

As I said I am just a novice.
So I want to get something small going.

Kind Regards,

Robert.


"Ashley Sheridan" <[email protected]> wrote in message
news:[email protected]...
On Mon, 2011-05-02 at 17:55 +1000, sir wally lewis wrote:

I am a complete novice at php.
My internet service provider gives me webspace and PHP script execution
for free.

I would like a simple example of a website that stores data on the
server, in simple text files.

Is this possible?

Kind Regards,

Robert



If you're storing data, try to use a database, as you can do a lot more with a DB than you can with flat text files on the server, and it's much
faster.

However, if you're stuck with text files, then look at things like
fopen, fwrite and file_get_contents functions, as these should help a
lot.

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








Look into the functions I mentioned, they have enough examples on the
php.net man pages to get you to a point where you can put some code
together to do what you need.

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



You might want to google flat file databases. There are systems that already do this.

Bastien Koert



He didn't say he necessarily wanted database-like functionality, just
that he wanted to be able to store data in text files. This could be
something as simple as a log, or basic CMS that generates the HTML pages
that make up a website.

SQLite, anyone?

That aside, learning how to deal with flat file databases on your own is not a bad idea at all. It's an excellent learning exercise.



--- End Message ---

Reply via email to