php-general Digest 13 Sep 2009 11:25:12 -0000 Issue 6337

Topics (messages 297957 through 297968):

Re: get an object property
        297957 by: Jan Reiter
        297967 by: Lars Torben Wilson

Mail Command Body Issue - Trying to use 'do while' loop
        297958 by: cool.hosting4days.com
        297959 by: cool.hosting4days.com
        297960 by: cool.hosting4days.com

PHP 5.3 & PECL & WINDOWS: Compile | VirtualPC | VirtualBox
        297961 by: steve

Odd Endless Loop with Explorer 8 (pc)
        297962 by: cool.hosting4days.com
        297963 by: kranthi
        297964 by: HallMarc Websites
        297965 by: cool.hosting4days.com

Re: Reading files in PHP 5.3.0
        297966 by: Paul M Foster

Re: [Formaldehyde] The Most Basic Ajax - PHP Error Debugger
        297968 by: Andrea Giammarchi

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 ---
I have to agree, your example works fine for me. For testing I used the
latest stable Release of server2go with PHP 5.2.10.

Or do you want to use something like that:

class o
{
        protected $arr = array('a'=>0);
        function o($n){$this->arr['a'] = $n;}
        function getA(){return $this->arr['a'];}
}

$o = array( new o(1), new o(2) );


if ( end($o)->getA() > 1 ) {  
echo "yeah";
}

Which works fine as well ... 

Regards,
jan

-----Original Message-----
From: Tom Worster [mailto:[email protected]] 
Sent: Saturday, September 12, 2009 1:31 AM
To: PHP General List
Subject: [PHP] get an object property

if i have an expression that evaluates to an object, the return value from a
function, say, and i only want the value of one of the objects properties,
is there a tidy way to get it without setting another variable?

to illustrate, here's something that doesn't work, but it would be
convenient if it did:

$o = array( (object) array('a'=>1), (object) array('a'=>2) );

if ( end($o)->a > 1 ) {  // can't use -> like this!
...
}




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Eingehende eMail ist virenfrei.
Von AVG überprüft - www.avg.de 
Version: 8.5.409 / Virendatenbank: 270.13.71/2336 - Ausgabedatum: 09/11/09
09:15:00 


--- End Message ---
--- Begin Message ---
Tom Worster wrote:
On 9/12/09 9:50 AM, "Tom Worster" <[email protected]> wrote:

On 9/12/09 1:32 AM, "Lars Torben Wilson" <[email protected]> wrote:

Tom Worster wrote:
if i have an expression that evaluates to an object, the return value from a
function, say, and i only want the value of one of the objects properties,
is there a tidy way to get it without setting another variable?

to illustrate, here's something that doesn't work, but it would be
convenient if it did:

$o = array( (object) array('a'=>1), (object) array('a'=>2) );

if ( end($o)->a > 1 ) {  // can't use -> like this!
...
}
What version of PHP are you using? Your example should work.

Torben
5.2.9.

what version does it work in?

i shamefully beg your pardon, lars. i was sure i tested the example but it's
clear to me now i either didn't or i made a mistake. end($o)->a IS php
syntax! so -> may follow a function (or method, i guess) call.
No need for apologies. :)
but let me give you a more different example:

$a and $b are normally both objects, each with various members including a
prop q, but sometimes $a is false. i want the q of $a if $a isn't false,
otherwise that of $b.

($a ? $a : $b)->q   // is not php, afaik

before you suggest one, i know there are simple workarounds.
You're right, that isn't PHP syntax. One workaround that came to mind which does
a similar thing (although using a different mechanism) is this:

 ${$a ? 'a' : 'b'}->q

but mine is a theoretical question about syntax, not a practical one. i'm
exploring php's syntactic constraints on the -> operator in contrast to,
say, the + or . operators. and in contrast to other languages.
I can respect that. This kind of exploration is often quite illuminating.
for example, the . in js seems more generally allowed than -> (or, for that
matter, []) in php. programmers (especially using jquery) are familiar with
using . after an expression that evaluates to an object, e.g.

<body>
<p id="thepara" class="top x23 indent">My x class number is
    <span id="num"></span></p>
<div id="mandatory" style="border: solid red 1px"></div>
<script type="text/javascript">
document.getElementById('num').innerText =
  ( ( document.getElementById('optional')
      || document.getElementById('mandatory')
    ).appendChild(document.getElementById('thepara'))
    .className.match(/x(\d+)/) || [0,'absent']
  )[1]
</script>
</body>

which shows . after objects, method calls and expressions (as well as the []
operator applied to an expression).

do we just live without in phpville or am i missing something?
We live without, just like we live without

$foo =~ s/bar/baz/i;

. . .and without:

cout << "Hello " << world << endl;

. . .and without:

#define FOO(bar, baz) ((bar) * (baz))

. . .and so on. It's just syntax from other languages which isn't part of the PHP syntax.
and while i'm at it, and using my original error, how come...

function o() { return (object) array('q'=>7); }
echo o()->q;  // is ok syntax, but

function a() { return array('q'=>5); }
echo a()['q'];  // isn't?
I'm afraid I can't answer that right now--it does perhaps seem inconsistent at first glance, although I can't say I've ever missed it or felt that using syntax like that would make my life any better. Maybe it would. Then again, I can also see an argument being made for allowing the object syntax but not the array syntax: in the case of objects, you can have a clean class declaration which is pretty much self-documenting, and later users of the class can have a clear idea of which properties are available and which are not, and they can thus be sure that o()->q will not result in uninitialized property problems. Using the array syntax you could never be sure that the index requested actually exists.

Of course, this holds true only for people like me who don't really like the idea of creating objects on the fly in PHP unless there's a very good reason to. Usually in PHP such tasks
are better handled by arrays anyway.

This is of course just random thinking and perhaps it's just because nobody has added
that syntax to the scanner. :)

Anyway, good luck with your language comparison. Like I said before, that kind of thing
is often fun (and always instructional).


Regards,

Torben

--- End Message ---
--- Begin Message --- I'm having a problem with mail body issue trying to use 'do while' loop in the $mail_body var.

this line:
do { echo $row_get1['name'] } while ($row_get1 = mysql_fetch_assoc ($get1))

will show ok when it's on the page elsewhere (not in the $mail_body var) but typed like:

--- ok on web page (not email)
<?php do {
echo $row_get1['vt_name']; } while ($row_get1 = mysql_fetch_assoc ($get1)); ?>

Q: i want "TEXT" LOOP "TEXT" - AM I MISSING some syntax characters like(; or??) somewhere or ????

THANKS for your help - dave

----- full email code --------

<?php
$mail_body = "test \n\n"."test2".do { echo 'test' } while ($row_get1 = mysql_fetch_assoc($get1))."Thanks
test xxx";  ?>

<?php
$Name = "test"; //senders name
$email = "[email protected]"; //senders e-mail adress
$recipientname = "[email protected]";
$recipient = "[email protected]"; //recipient
$subject = "test".
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
$fullto = $recipientname . " <" . $recipient . ">";
//$fullto = $recipientname . " <" . $recipient . ">".", ".$recip2;
ini_set('sendmail_from', '[email protected]');

mail($fullto, $subject, $mail_body, $header); //mail command :)
?>



Thanks,
[email protected]






--- End Message ---
--- Begin Message --- I'm having a problem with mail body issue trying to use 'do while' loop in the $mail_body var.

this line:
do { echo $row_get1['name'] } while ($row_get1 = mysql_fetch_assoc ($get1))

will show ok when it's on the page elsewhere (not in the $mail_body var) but typed like:

--- ok on web page (not email)
<?php do {
echo $row_get1['vt_name']; } while ($row_get1 = mysql_fetch_assoc ($get1)); ?>

Q: i want "TEXT" LOOP "TEXT" - AM I MISSING some syntax characters like(; or??) somewhere or ????

THANKS for your help - dave

----- full email code --------

<?php
$mail_body = "test \n\n"."test2".do { echo 'test' } while ($row_get1 = mysql_fetch_assoc($get1))."Thanks
test xxx";  ?>

<?php
$Name = "test"; //senders name
$email = "[email protected]"; //senders e-mail adress
$recipientname = "[email protected]";
$recipient = "[email protected]"; //recipient
$subject = "test".
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
$fullto = $recipientname . " <" . $recipient . ">";
//$fullto = $recipientname . " <" . $recipient . ">".", ".$recip2;
ini_set('sendmail_from', '[email protected]');

mail($fullto, $subject, $mail_body, $header); //mail command :)
?>



Thanks,
[email protected]






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

On Sep 12, 2009, at 3:47 PM, [email protected] wrote:

I'm having a problem with mail body issue trying to use 'do while' loop in the $mail_body var.

this line:
do { echo $row_get1['name'] } while ($row_get1 = mysql_fetch_assoc ($get1))

will show ok when it's on the page elsewhere (not in the $mail_body var) but typed like:

--- ok on web page (not email)
<?php do {
echo $row_get1['vt_name']; } while ($row_get1 = mysql_fetch_assoc ($get1)); ?>

Q: i want "TEXT" LOOP "TEXT" - AM I MISSING some syntax characters like(; or??) somewhere or ????

THANKS for your help - dave


I got it working like this....

<?php

$loop1 = '';

do {
$loop1 = $loop1."\n".$row_get1['vt_name'].' - ';
} while ($row_get1 = mysql_fetch_assoc($get1));



$mail_body = "test \n\n"."test2 ".$loop1."Thanks
test xxx";  ?>


Q: is this the best way?




----- full email code --------

<?php
$mail_body = "test \n\n"."test2".do { echo 'test' } while ($row_get1 = mysql_fetch_assoc($get1))."Thanks
test xxx";  ?>

<?php
$Name = "test"; //senders name
$email = "[email protected]"; //senders e-mail adress
$recipientname = "[email protected]";
$recipient = "[email protected]"; //recipient
$subject = "test".
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
$fullto = $recipientname . " <" . $recipient . ">";
//$fullto = $recipientname . " <" . $recipient . ">".", ".$recip2;
ini_set('sendmail_from', '[email protected]');

mail($fullto, $subject, $mail_body, $header); //mail command :)
?>



Thanks,
[email protected]






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




Thanks,
[email protected]






--- End Message ---
--- Begin Message ---
Since it has been about a year with no PECL extensions for windows,
and I don't think theire ever will be, and I want to move to 5.3,
there are tough choices.

A: I can try downloading from source and compiling the pecl binaries
on windows. No experience compiling on windows, but I guess I can go
there...

B: Install a stripped down non-gui version of Ubuntu into VirtualPC or
VirtualBox, both of which I have on Windows7 here. Anyone know what
the performance of either would be? does one work faster than the
other? If we go this route, I might also have the Mac people do this
too.

Thanks!

--- End Message ---
--- Begin Message ---
I have many of these tags on a site...

They work well with all browsers i've tested - except  explorer 8 (pc)

<?php echo '<meta http-equiv="refresh" content="0;page2.php">'; ?>

It just goes into an endless loop but stays on the original page - never going to page2.php


Q: Any idea how to fix this?




Thanks,
[email protected]






--- End Message ---
--- Begin Message ---
> <?php echo '<meta http-equiv="refresh" content="0;page2.php">'; ?>
may b u should have
<?php echo '<meta http-equiv="refresh" content="0;url=page2.php">'; ?>

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

> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> Sent: Saturday, September 12, 2009 10:39 PM
> To: [email protected]
> Subject: [PHP] Odd Endless Loop with Explorer 8 (pc)
> 
> I have many of these tags on a site...
> 
> They work well with all browsers i've tested - except  explorer 8 (pc)
> 
> <?php echo '<meta http-equiv="refresh" content="0;page2.php">'; ?>
> 
> It just goes into an endless loop but stays on the original page -
> never going to page2.php
> 
> 
> Q: Any idea how to fix this?
> 
> 
> 
> 
> Thanks,
> [email protected]
> 
> 

[HallMarc Websites] 
you are missing url=page2.php

<?php echo '<meta HTTP-EQUIV="refresh" CONTENT="0; url=page2.php">'; ?>
 

__________ Information from ESET Smart Security, version of virus signature
database 4420 (20090912) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 


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

On Sep 12, 2009, at 7:57 PM, kranthi wrote:

<?php echo '<meta http-equiv="refresh" content="0;page2.php">'; ?>
may b u should have
<?php echo '<meta http-equiv="refresh" content="0;url=page2.php">'; ?>

Thanks kranthi & HallMarc Websites

url= ... - that did the trick!



Thanks,
[email protected]






--- End Message ---
--- Begin Message ---
On Sat, Sep 12, 2009 at 10:22:10AM -0400, tedd wrote:

> At 6:02 PM -0400 9/11/09, Paul M Foster wrote:
>>
>> I typically use us2.php.net, which is hosted by Hurricane Electric.
>>
>> Paul
>
> Paul:
>
> I wouldn't use Hurricane Electric if their accounts were provided for free!
>
> The following is an experience I had with Hurricane Electric and
> support for my opinion as to their "service".
>
> You see, many years ago Hurricane Electric hosted (IMO with
> complicity) a porn site that sent out over 2000 porn spams to AOL
> using MY email address as the person to contact. That incident caused
> me a great deal of trouble.
>
> In an attempt to understand and resolve the problem, I sent several
> emails to Hurricane Electric; I called them numerous times via
> telephone; and I even sent them letters via the US mail. But
> unfortunately they refused to answer ANY of my correspondence. Their
> lack of communication provided support for my opinion of their
> complicity with what had happened.
>
> A few years back they contacted me (again more spam) soliciting my
> interest in hosting with them. Normally, I would have just reported
> such spam to spamcop, but because of the incident I replied and told
> them what had happened.
>
> Later I was contacted by one of their technicians who looked thorough
> their records and confirmed/admitted the incident. However, he told
> me that they could not be held responsible for they clients they
> host. Furthermore, they have no intention of screening their clients.
> He said that they will provide hosting to whomever they want,
> including porn and spam sites. If their clients do anything wrong per
> "their standards", then they will deal with it internally. Otherwise
> they don't care about any harm done to anyone by them hosting such
> sites. In short, they want the money but not the responsibility.
>
> Now, maybe Hurricane Electric has changed its ways, but they can't
> change their past.
>
> In my opinion, there are more than enough hosting companies who care
> about the damage they might cause and take steps to reduce the about
> spam and porn on the net. My advice, seek hosts other than Hurricane
> Electric.

I don't know much about HE, other than the fact that they run ads in
Linux Journal. But they're a real hosting company, like Rackspace or
1and1. Yahoo (who hosts www.php.net) isn't a company I think of as a
hosting company. And they're an internet behemoth, like Godaddy or
Microsoft. So I'd personally steer away from them. Just my bias.

It sounds like HE's real problem is their TOS. I've hosted with a lot of
companies who will drop accounts where they find porn, spam and warez;
it's part of their TOS. The other problem I can see is that they are
apparently unwilling to even mediate a problem between two of their
accounts. "We just host 'em. Other than that, we don't care." Typical. I
expect the porn company paid them a *lot* more money than you did, so
they simply looked the other way. A shame.

The lesson, I suppose, is to look at the terms of service before you
sign up with a hosting company. You may still end up being a victim, but
at least you know what you're getting yourself into. If they don't
specifically disavow porn, spam and warez, then they allow (and in
effect, condone) it.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
That I created some fresh air or something new? Sure, thanks

> Date: Sat, 12 Sep 2009 11:47:27 -0700
> From: [email protected]
> To: [email protected]
> CC: [email protected]; [email protected]
> Subject: Re: [PHP] RE: [Formaldehyde] The Most Basic Ajax - PHP Error Debugger
> 
> Andrea Giammarchi wrote:
> > something I cannot find in any other library or framework.
> 
> This should tell you something then...
> 
> -- 
> Jim Lucas
> 
>     "Some men are born to greatness, some achieve greatness,
>         and some have greatness thrust upon them."
> 
> Twelfth Night, Act II, Scene V
>      by William Shakespeare

_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

--- End Message ---

Reply via email to