php-general Digest 25 Jul 2005 01:31:15 -0000 Issue 3586

Topics (messages 219269 through 219281):

Re: System specific information gathering
        219269 by: André Medeiros

Send in a form there email
        219270 by: Thomas Bonham
        219271 by: Thomas Bonham
        219280 by: Richard Lynch

quick question about using capital letters coding w/ PHP
        219272 by: Bruce Gilbert
        219273 by: Dotan Cohen
        219276 by: Matthew Weier O'Phinney
        219278 by: Chris Shiflett
        219279 by: Richard Lynch

Re: preg_match_all question
        219274 by: Chris Bruce

DOM->schemaValidate - line numbers??
        219275 by: John Smith

is_array() doesn't work on DOM properties?
        219277 by: John Smith

Re: gloabl & reference behavior question?
        219281 by: Richard Lynch

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Or that... :P

On 7/24/05, Joe Wollard <[EMAIL PROTECTED]> wrote:
> As always, look for someone else's existing project and see how they
> did it. ;-)
> 
> http://phpsysinfo.sourceforge.net/
> 
> Good Luck!
> -Joe
> 
> On Jul 23, 2005, at 9:25 AM, André Medeiros wrote:
> 
> > First of all, you want to have the two values in seperate variables.
> > After reading the contents from the file, do something like:
> >
> > -----------------------------------------8<---------------------------
> > ------------------
> > function parseUptimeSeconds( $seconds ) {
> >     $resultArray = Array( 'weeks' => 0, 'days' => 0, 'hours' => 0,
> > 'minutes' => 0, 'seconds' =>  0);
> >
> >     // check weeks
> >     while( $seconds > 604800 ) {
> >         $resultArray['weeks']++;
> >         $seconds -= 604800;
> >     }
> >
> >     // check days
> >     while( $seconds > 86400) {
> >         $resultArray['days']++;
> >         $seconds -= 86400;
> >     }
> >
> >     // check hours
> >     while( $seconds > 3600) {
> >         $resultArray['hours']++;
> >         $seconds -= 3600;
> >     }
> >
> >     // check minutes
> >     while( $seconds > 60) {
> >         $resultArray['minutes']++;
> >         $seconds -= 60;
> >     }
> >
> >     $resultArray['seconds'] = $seconds;
> >
> >     return( $resultArray );
> > }
> >
> > // separate both values
> > list( $uptimeSeconds, $idleSeconds ) = explode( ' ',
> > $lineReadFromFile );
> > $uptimeElements = parseUptimeSeconds( $uptimeSeconds );
> > $idleElements = parseUptimeSeconds( $idleSeconds );
> > -----------------------------------------8<---------------------------
> > ------------------
> >
> > I know there might be a more efficient way of doing this, like using
> > the modulus operator, but hey :)
> >
> > On 7/23/05, Ramil Sagum <[EMAIL PROTECTED]> wrote:
> >
> >> On 7/23/05, Vidyut Luther <[EMAIL PROTECTED]> wrote:
> >>
> >>> Ok,
> >>>   If I use the file_get_contents.. how do I actually parse the
> >>> contents on /proc/uptime
> >>> cat /proc/uptime
> >>> 1400293.13 1317047.64
> >>>
> >>
> >>
> >> The first number is the total uptime in seconds, the second number is
> >> the total idle time.
> >>
> >> --
> >> ----
> >>
> >>
> >>
> >> ramil
> >> http://ramil.sagum.net/
> >>
> >> --
> >> 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
> >
> >
> 
>

--- End Message ---
--- Begin Message ---
Hello All,
I'm trying to format a the variables for the form to send them there
email. What I need is how do I put a new line in the string that is be
send.

Thanks 
Thomas
-- 
------------------------------------------------------------------
Thomas Bonham RHCT (Red Hat Certified Technician)
[EMAIL PROTECTED]
bonhamlinux.org
Cell 602-402-9786

--- End Message ---
--- Begin Message ---
I fond the fix.

When you use \n in the string and then try to echo it back it doesn't echo back right. But when you send it the \n works.

Thomas


Thomas Bonham wrote:
Hello All,
I'm trying to format a the variables for the form to send them there
email. What I need is how do I put a new line in the string that is be
send.

Thanks Thomas

--- End Message ---
--- Begin Message ---
On Sun, July 24, 2005 8:22 am, Thomas Bonham said:
> When you use \n in the string and then try to echo it back it doesn't
> echo back right. But when you send it the \n works.

Oh, it echos back correctly...

But your BROWSER, which you were using to view it, IGNORES newlines. Or,
more properly, it treats one or more whitespace characters (space,
newline, tab) as a single space.

If you use "View Source" in your browser, you'd see more what you expect.

Or you could use http://php.net/nl2br for HTML output.

Or you could use PRE tags.

Or you could use PHP from the command line.

Or you could use some kind of software to see the raw output of your
web-server, though that's probably a bit more trouble than needed...

> Thomas Bonham wrote:
>> Hello All,
>> I'm trying to format a the variables for the form to send them there
>> email. What I need is how do I put a new line in the string that is be
>> send.

-- 
Like Music?
http://l-i-e.com/artists.htm

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

I am well versed in coding with xhtml which requires all lower case
and am pretty much a newbie at PHP so that is why I am asking this
question.

is this acceptible 

if ($_post [sender_email] == "") or does at have to be if ($_POST
[sender_email] == "")

in short, do uppercase and lowercase always have the same meaning.

thx,

--- End Message ---
--- Begin Message ---
On 7/24/05, Bruce Gilbert <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I am well versed in coding with xhtml which requires all lower case
> and am pretty much a newbie at PHP so that is why I am asking this
> question.
> 
> is this acceptible
> 
> if ($_post [sender_email] == "") or does at have to be if ($_POST
> [sender_email] == "")
> 
> in short, do uppercase and lowercase always have the same meaning.
> 
> thx,
> 

PHP is case-sensitive. UppERCase is NOT the same as uppercase. HTML is
not case sensitive only because browsers are forgiving.

Dotan
http://lyricslist.com/lyrics/artist_albums/282/john_elton.php
John, Elton Song Lyrics

--- End Message ---
--- Begin Message ---
* Bruce Gilbert <[EMAIL PROTECTED]>:
> I am well versed in coding with xhtml which requires all lower case
> and am pretty much a newbie at PHP so that is why I am asking this
> question.
>
> is this acceptible 
>
> if ($_post [sender_email] == "") or does at have to be if ($_POST
> [sender_email] == "")
>
> in short, do uppercase and lowercase always have the same meaning.

PHP is case sensitive. Additionally, quotes, or the absense of quotes,
can change the context. I bring this up because the example you have
above, $_post[sender_email] contains two errors:

* $_post will likely be empty, whereas the PHP superglobal $_POST will
  likely contain the data you're looking for ;-)
* $_post[sender_email] refers to the value in the $_post array returned
  by an array key that is the same name as the value of the constant
  sender_email. You almost certainly were actually meant
  $_POST['sender_email'] (note the quotes), which would refer to the
  value associated with the array key 'sender_emaail' in the $_POST
  array.

You should probably do some reading in the introductory chapters of the
PHP manual, specifically the variables section:

    http://php.net/variables

Cheers!

-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

--- End Message ---
--- Begin Message ---
Bruce Gilbert wrote:
is this acceptible
if ($_post [sender_email] == "") or does at have to be if ($_POST
[sender_email] == "")

As a friendly suggestion, you should always try before you ask. You could answer your own question with a few seconds of effort. Typically, such extreme laziness is not rewarded here. Consider yourself lucky this time. :-)

If you had instead asked whether you should use $_POST[sender_email] or $_POST['sender_email'], at least we could give you the benefit of the doubt and assume that you actually tried them both.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--- End Message ---
--- Begin Message ---
On Sun, July 24, 2005 11:39 am, Dotan Cohen said:
> On 7/24/05, Bruce Gilbert <[EMAIL PROTECTED]> wrote:
>> I am well versed in coding with xhtml which requires all lower case
>> and am pretty much a newbie at PHP so that is why I am asking this
>> question.
>>
>> is this acceptible
>>
>> if ($_post [sender_email] == "") or does at have to be if ($_POST
>> [sender_email] == "")
>>
>> in short, do uppercase and lowercase always have the same meaning.
>>
>> thx,
>>
>
> PHP is case-sensitive. UppERCase is NOT the same as uppercase. HTML is
> not case sensitive only because browsers are forgiving.

PHP variables are case-sensitive.

PHP FUNCTIONS are not.

You're on your own figuring out if class names/methods are/aren't
case-sensitive this week. :-v

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
It matches any link with the exception of https links.

On Jul 20, 2005, at 3:36 PM, Ethilien wrote:

I don't see anything in this regex that would prevent https from being matched, since you don't specify the pattern of the actual url at all.

What is an example of a link that it will match?

Chris Bruce wrote:
Hello,
I am using the following to do link replacing:
preg_match_all("/<\s*a\s+[^>]*href\s*=\s*[\"']?([^\"' >]+)[\"' >]/isU",$file[$x],$matches); It works great for all but 'https' links. I am not that versed in regular expressions. Would anyone know what I need to put in there so that it will match on https links?
Thanks,
Chris

--- End Message ---
--- Begin Message ---
I'm validating an XML document against a schema using
PHP 5's DomDocument. Easy enough to use, however it
doesn't output the line numbers of errors in the XML
file! Anybody know if it's possible?

Thanks,
John

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
I'm trying to avoid error messages while iterating
over DOM properties. e.g.

if(is_array($dom->stuff->props)) {
  foreach($dom->stuff->props as $prop) {
    ...
  }
}

It works without the is_array() check, but not with
it. I've done var_dumps and $dom->stuff->props is
indeed an array. I've also tried using an intermediate
variable ($stuff=$dom->stuff) then checking that, but
that doesn't work either).

John


                
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 

--- End Message ---
--- Begin Message ---
On Fri, July 22, 2005 11:46 am, Surendra Singhi said:
>
> "Richard Lynch" <[EMAIL PROTECTED]> writes:
>> The & operator is not, as far as I know, defined for an array assignment
>> operation.
>>
>> True, you can use & in the parameter list in some versions to keep PHP
>> from copying the whole array.  But that does not legitimatize what you
>> are
>> doing, I don't think.
>
> I never claimed, what I was doing was correct, rather I didn't knew well
> enough that 'PHP is not C++', and I was misunderstanding how reference and
> global variables work in PHP.
>>
>> I could be 100% wrong. I've never even *TRIED* to use a reference to an
>> array because I simply don't want to write code that confusing in the
>> first place.
>
> I don't think it will make the code confusing, but the person looking at
> the
> code should understand how reference and global variables work. Using
> reference variables avoids unnecessary extra copying of objects, and while
> using large arrays it can make a big difference in speed.
>
> The lesson to learn from this thread is that variables declared in a
> function
> as global (using global keyword) are new reference variables to the actual
> global variable. And, so when these global variables in functions are
> assigned
> a new reference, it breaks the old reference and makes them refer to the
> new
> location, and the actual global variable is not affected.
> But in contrast, if the global variables in the function are assigned a
> new
> value, this does changes the value of the variable in the outer global
> scope.

Well, *I* would be confused by the globals, references, and whatnot you've
got running around...

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---

Reply via email to