php-general Digest 21 Dec 2007 13:46:33 -0000 Issue 5193
Topics (messages 266192 through 266202):
Re: building PHP5.2.5 on Mac OS X Leopard (anyone know how to build a just an
extension)
266192 by: Jochem Maas
266193 by: Jochem Maas
266195 by: Jochem Maas
Re: about __get,__set Overloading, read-only properties
266194 by: Jochem Maas
266196 by: ked
Re: Which file called the function?
266197 by: Shelley Shyan
Re: Assign variable to a block of html code
266198 by: Xavier de Lapeyre
266199 by: Xavier de Lapeyre
Re: Just to confirm...
266200 by: Xavier de Lapeyre
266202 by: Nathan Rixham
Re: php sockets
266201 by: vixle
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 ---
Frank Arensmeier schreef:
>
> 20 dec 2007 kl. 00.55 skrev Jochem Maas:
>
>> hi guys,
>>
>> well having tried for countless hours to build php on leopard I pretty
>> much gave up.
> that's too bad...
'give up' is too strong - but deadlines and frustration has caused me to put
it aside right now.
>
...
>>
>> I figured I'd try using Marc' configure line (as given by
>> /usr/local/php5/bin/php-config against the
>> source of php5.2.5 that I downloaded and add the relevant configure
>> option (--with-interbase[=DIR])
>> ... in the hope I at least get a couple of usable extensions so that I
>> could copy the ibase extension
>> over into the working php5.2.5 installation ... no joy.
>>
> what error(s) did you get?
configure failed to find the interbase lib/headers (which it does find if
I run my own configure line that links against installed libs/headers - although
make then failed due to problems with iconv) if I use Marc's configure line
(which links against his supplied libs - I use --with-interbase=/opt
>> I figure I'm screwed - I have a painfully expensive dev machine I
>> can't blooming use. oh well,
>> at least it is the nicest looking paper weight I've got.
>>
> that's something, isn't it??
very funny :-)
>
>> I'm still wondering whether it's possible to build just the interbase
>> extension ... anyone know
>> how to do that? or have any tips?
> is interbase available via PEAR or PECL?
> How desperately are you trying
> to get thinks working? I mean, are you working on a project right now
> with a tight deadline? I really would like to help with the install
> (since I would like to update to Leopard in the near future as well, it
> might be a good opportunity to learn a few things), but right now I
> don't feel that I have the time...
>
>>
>> rgds,
>> Jochem
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
--- End Message ---
--- Begin Message ---
Daniel Brown schreef:
> On Dec 20, 2007 2:30 PM, Richard Lynch <[EMAIL PROTECTED]> wrote:
>> ./configure --with-interbase
>>
>> should build the interbase extension, as well as a PHP binary that you
>> don't want.
>>
>> Then just copy the interbase.so thingie over, and Bob's your uncle.
>
> I don't know who Bob is, but it should also be mentioned that you
> need to run 'make', but NOT 'make install'. Richard didn't insinuate
> that you would, but I'm just directly stating it.
Richard, Dan, thanks for thinking with me on this.
I did try this already. I even tried ./configure --disable-all --with-interbase
in order to try and kill as many dependencies as possible. no joy, configure
runs to the end (but also warns me me system seems to be borked) and make
bombs out completely halfway through.
I'll give it a stab again tomorrow - no doubt there are a million or so
configure variations I have yet to try - I'll get back with some details that
may allow someone to give me a lightbulb moment.
PS - did I mention that I'm way out of my depth with all these make errors
and library linking stuff :)
>
--- End Message ---
--- Begin Message ---
I hit send too soon ...
Frank Arensmeier schreef:
>
> 20 dec 2007 kl. 00.55 skrev Jochem Maas:
...
> is interbase available via PEAR or PECL?
alas no. it would be PECL at any rate - and I don't hold much faith in PECL
being able to build anything usable anyway
> How desperately are you trying
> to get thinks working?
desperate enough to move back to my windows machine ;-)
> I mean, are you working on a project right now
> with a tight deadline?
I have 2 running projects with ongoing deadlines that I should be working on
instead of trying to get php working on my Mac - customers call daily asking
when
stuff will be rolled out.
> I really would like to help with the install
> (since I would like to update to Leopard in the near future as well, it
> might be a good opportunity to learn a few things), but right now I
> don't feel that I have the time...
good to know. I'll have another stab at it tomorrow and give details regarding
the configure lines I'm using and the libsI have installed, etc - I did a rm -rf
on everything related to php5 and apache2 in a fit of rage so I can't retrieve
anything useful right this minute.
in the mean time I'd like to ask:
1. do you have Xcode installed?
2. do you use macports for installing stuff like libjpeg?
--- End Message ---
--- Begin Message ---
pleae don't reply to an existing thread when posting a new question.
ked schreef:
> Hi. all ,
>
> I got a article from php 5.0 manual's comments. It's useful, offer readonly
> properties for classes.
>
> (look at the end of this message for the article )
>
> find out function __construct(), I want to modify $this->id in it , then I
> got a "readonly" Exception (defined in "__set" function).
>
> Distinctly, a read-only property could not be change via "$obj->attribute =
> '' " ,
> but is could be change via $this->id='', inside of class , isn't it ?
>
> How to modify __set function ?
don't - let __set() be the policeman it's supposed to be.
either create a private function to initialize values or set the values
directly in the array
private function init($k, $v)
{
if (isset($this->p_arrPublicProperties[$k]))
$this->p_arrPublicProperties[$k]['value'] = $v;
}
>
> thanks for any advises.
>
> regards!
> ked
>
>
> the article is here:
> ----------------------------------------------------------------------------
> ------------------------
> Eric Lafkoff (22-Feb-2006 02:56)
>
> If you're wondering how to create read-only properties for your class, the
> __get() and __set() functions are what you're looking for. You just have to
> create the framework and code to implement this functionality.
> Here's a quick example I've written. This code doesn't take advantage of the
> "type" attribute in the properties array, but is there for ideas.
> <?php
> class Test
> {
> private $p_arrPublicProperties = array(
> "id" => array("value" => 4,"type" => "int","readonly" => true),
> "datetime" => array("value" => "Tue 02/21/2006 20:49:23","type" =>
> "string", "readonly" => true),
> "data" => array("value" => "foo", "type" => "string", "readonly" =>
> false)
> );
>
> //ked add!!!!!!!
> public function __construct()
> {
> $this->id = 100; //----------------------------will get exception
> !!
> }
>
> private function __get($strProperty) {
> //Get a property:
> if (isset($this->p_arrPublicProperties[$strProperty])) {
> return $this->p_arrPublicProperties[$strProperty]["value"];
> } else {
> throw new Exception("Property not defined");
> return false;
> }
> }
>
> private function __set($strProperty, $varValue) {
> //Set a property to a value:
> if (isset($this->p_arrPublicProperties[$strProperty])) {
> //Check if property is read-only:
> if ($this->p_arrPublicProperties[$strProperty]["readonly"]) {
> throw new Exception("Property is read-only");
> ///////////////////////////////////---------------note here
> return false;
> } else {
> $this->p_arrPublicProperties[$strProperty]["value"] = $varValue;
> return true;
> }
> } else {
> throw new Exception("Property not defined");
> return false;
> }
> }
>
> private function __isset($strProperty) {
> //Determine if property is set:
> return isset($this->p_arrPublicProperties[$strProperty]);
> }
>
> private function __unset($strProperty) {
> //Unset (remove) a property:
> unset($this->p_arrPublicProperties[$strProperty]);
> }
>
> }
> $objTest = new Test();
> print $objTest->data . "\n";
> $objTest->data = "bar"; //Works.
> print $objTest->data;
> $objTest->id = 5; //Error: Property is read-only.
> ?>
>
--- End Message ---
--- Begin Message ---
My idea is just your answer...happy..ing ^_^
You are so warmhearted. Thanks a lot! : )
I will never post a question to a existing thread .
> -----Original Message-----
> From: Jochem Maas [mailto:[EMAIL PROTECTED]
> Sent: Friday, December 21, 2007 9:11 AM
> To: ked
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] about __get,__set Overloading, read-only properties
>
> pleae don't reply to an existing thread when posting a new question.
>
> ked schreef:
> > Hi. all ,
> >
> > I got a article from php 5.0 manual's comments. It's useful, offer
> > readonly properties for classes.
> >
> > (look at the end of this message for the article )
> >
> > find out function __construct(), I want to modify
> $this->id in it ,
> > then I got a "readonly" Exception (defined in "__set" function).
> >
> > Distinctly, a read-only property could not be change via
> > "$obj->attribute = '' " , but is could be change via
> $this->id='',
> > inside of class , isn't it ?
> >
> > How to modify __set function ?
>
> don't - let __set() be the policeman it's supposed to be.
> either create a private function to initialize values or set
> the values directly in the array
>
> private function init($k, $v)
> {
> if (isset($this->p_arrPublicProperties[$k]))
> $this->p_arrPublicProperties[$k]['value'] = $v; }
>
> >
> > thanks for any advises.
> >
> > regards!
> > ked
> >
> >
> > the article is here:
> >
> ----------------------------------------------------------------------
> > ------
> > ------------------------
> > Eric Lafkoff (22-Feb-2006 02:56)
> >
> > If you're wondering how to create read-only properties for
> your class,
> > the
> > __get() and __set() functions are what you're looking for. You just
> > have to create the framework and code to implement this
> functionality.
> > Here's a quick example I've written. This code doesn't take
> advantage
> > of the "type" attribute in the properties array, but is
> there for ideas.
> > <?php
> > class Test
> > {
> > private $p_arrPublicProperties = array(
> > "id" => array("value" => 4,"type" => "int","readonly" => true),
> > "datetime" => array("value" => "Tue 02/21/2006
> 20:49:23","type" =>
> > "string", "readonly" => true),
> > "data" => array("value" => "foo", "type" => "string",
> "readonly" =>
> > false)
> > );
> >
> > //ked add!!!!!!!
> > public function __construct()
> > {
> > $this->id = 100; //----------------------------will get
> exception !!
> > }
> >
> > private function __get($strProperty) { //Get a property:
> > if (isset($this->p_arrPublicProperties[$strProperty])) { return
> > $this->p_arrPublicProperties[$strProperty]["value"];
> > } else {
> > throw new Exception("Property not defined"); return false; } }
> >
> > private function __set($strProperty, $varValue) { //Set a
> property to
> > a value:
> > if (isset($this->p_arrPublicProperties[$strProperty])) { //Check if
> > property is read-only:
> > if ($this->p_arrPublicProperties[$strProperty]["readonly"]) { throw
> > new Exception("Property is read-only");
> > ///////////////////////////////////---------------note here return
> > false; } else {
> $this->p_arrPublicProperties[$strProperty]["value"] =
> > $varValue; return true; } } else { throw new
> Exception("Property not
> > defined"); return false; } }
> >
> > private function __isset($strProperty) {
> > //Determine if property is set:
> > return isset($this->p_arrPublicProperties[$strProperty]);
> > }
> >
> > private function __unset($strProperty) {
> > //Unset (remove) a property:
> > unset($this->p_arrPublicProperties[$strProperty]);
> > }
> >
> > }
> > $objTest = new Test();
> > print $objTest->data . "\n";
> > $objTest->data = "bar"; //Works.
> > print $objTest->data;
> > $objTest->id = 5; //Error: Property is read-only.
> > ?>
> >
>
> --
> PHP General Mailing List (http://www.php.net/) To
> unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--- End Message ---
--- Begin Message ---
Richard is right.
If you want to get where __FILE__ is exactly in, __FILE__ is the option.
Else, use $_SERVER['PHP_SELF']. (And this should be what you expected)
Regards,
Shelley
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Christoph Boget
Sent: Thursday, December 20, 2007 10:37 PM
To: PHP General
Subject: [PHP] Which file called the function?
Let's say I have the following 3 files
global.php
<?
function myFunc() { echo __FILE__; }
?>
one.php
<?
include( 'global.php' );
echo 'You are in file: ';
myFunc();
?>
two.php
<?
include( 'global.php' );
echo 'You are in file: ';
myFunc();
?>
In each case, what is echoed out for __FILE__ is global.php. Apart from
analyzing the debug_backtrace array, is there any way that myFunc() would
display "one.php" and "two.php" respectively?
thnx,
Christoph
--- End Message ---
--- Begin Message ---
Yeps,
Sorry bout that.
Thnks for pointing it out.
Xavier
-----Original Message-----
From: Darren Whitlen [mailto:[EMAIL PROTECTED]
Sent: jeudi 20 décembre 2007 13:13
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Assign variable to a block of html code
Xavier de Lapeyre wrote:
> You should try the HEREDOC structure.
> See link: http://php.net/heredoc
>
> It should look to something like:
>
> $myblokvar = <<<EOF
> <table blabla>
> <tr>
> <td>
> Welcome $name to this website!
> </td>
> </tr>
> </table>
> <<<EOF;
Xavier,
You should test this before you send it.. it doesn't even parse!
The closing EOF should not start with the "<<<". It should only be the
identifier ("EOF") followed by ; and a new line.
-----
$myblokvar = <<<EOF
<table blabla>
.....
....
EOF;
-----
Darren
>
> No need of quotes or php start/end tags when placing a variable.
>
> To use it afterwards simply call the $mylokvar variable.
>
> Hope it helped!
>
> Xavier
> Web Developer
> Site: www.eds.mu
>
>
>
>
> -----Original Message-----
> From: Stephen Johnson [mailto:[EMAIL PROTECTED]
> Sent: jeudi 20 décembre 2007 07:43
> To: php mail; PHP General List
> Subject: Re: [PHP] Assign variable to a block of html code
>
> What you have will work, you just need to escape out the double quotes in
> the html.
>
>
>
>
> On 12/19/07 7:38 PM, "php mail" <[EMAIL PROTECTED]> wrote:
>
>> Hi All,
>>
>> Is it possible to assign variable to a block of html code ?
>>
>> Something like this :
>>
>> $myblokvar = "
>> <table width="487" border="0" cellspacing="0" cellpadding="0">
>> <tr>
>> <td><table width="487" border="0" cellspacing="0" cellpadding="0">
>> <tr>
>> <td><img src="images/bartitle_login.gif" alt="Login" width="475"
>> height="30" /></td>
>> <td> </td>
>> </tr>
>> <tr>
>> <td class="produk"><table width="100%" border="0" cellpadding="3"
>> cellspacing="2">
>> <tr>
>> <td class="katalog">
>> <?=$log_info?>
>> </td>
>> </tr>
>> </table></td>
>> <td> </td>
>> </tr>
>> <tr>
>> <td class="produk"> </td>
>> <td> </td>
>> </tr>
>> </table></td>
>> </tr>
>> </table>
>> ";
>>
>> Although example above is not working, what I want to achieve is something
>> like that. Is it possible how can I do that ?
>>
>> Regards,
>>
>> Feris
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Quote:
"
You could just swap all the double quotes in the HTML tags for single quotes -
that would work in this instance...
$myblokvar = "
<table width='487' border='0' cellspacing='0' cellpadding='0'>
...
</table>
";
"
That's a way too, but it does not preserve the indentation.
The HEREDOC syntax behave much like the <pre> HTML tag for PHP, and it also
removed the hassle of placing escape tags!
Xavier de Lapeyre
Web Developer
Enterprise Data Services
24, Dr Roux Street,
Rose Hill
Office: (230) 465 17 00
Fax: (230) 465 29 00
Site: www.eds.mu
-----Original Message-----
From: Peter Ford [mailto:[EMAIL PROTECTED]
Sent: jeudi 20 décembre 2007 13:17
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Assign variable to a block of html code
You could just swap all the double quotes in the HTML tags for single quotes -
that would work in this instance...
$myblokvar = "
<table width='487' border='0' cellspacing='0' cellpadding='0'>
...
</table>
";
Or perhaps a HereDoc syntax:
$myblokvar = <<<EndOfMyHTMLBlock
<table width="487" border="0" cellspacing="0" cellpadding="0">
...
</table>
EndOfMyHTMLBlock;
Then you don't need to worry about what quotes you use, and if you start putting
stuff like onclick events in you can mix quotes up happily ...
I go to great lengths to avoid escaping quotes - it just looks ugly.
That is, however, a personal foible.
Cheers
Pete
Stephen Johnson wrote:
> What you have will work, you just need to escape out the double quotes in
> the html.
>
>
>
>
> On 12/19/07 7:38 PM, "php mail" <[EMAIL PROTECTED]> wrote:
>
>> Hi All,
>>
>> Is it possible to assign variable to a block of html code ?
>>
>> Something like this :
>>
>> $myblokvar = "
>> <table width="487" border="0" cellspacing="0" cellpadding="0">
>> <tr>
>> <td><table width="487" border="0" cellspacing="0" cellpadding="0">
>> <tr>
>> <td><img src="images/bartitle_login.gif" alt="Login" width="475"
>> height="30" /></td>
>> <td> </td>
>> </tr>
>> <tr>
>> <td class="produk"><table width="100%" border="0" cellpadding="3"
>> cellspacing="2">
>> <tr>
>> <td class="katalog">
>> <?=$log_info?>
>> </td>
>> </tr>
>> </table></td>
>> <td> </td>
>> </tr>
>> <tr>
>> <td class="produk"> </td>
>> <td> </td>
>> </tr>
>> </table></td>
>> </tr>
>> </table>
>> ";
>>
>> Although example above is not working, what I want to achieve is something
>> like that. Is it possible how can I do that ?
>>
>> Regards,
>>
>> Feris
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
> <?
> if(stristr($_SERVER['HTTP_USER_AGENT'],"msie")) {
> die("No friend of Internet Exploder is a friend of mine.");
> }
> ?>
Lol!!! I need to implement that on ALL my sites ... XD!!
Xavier de Lapeyre
-----Original Message-----
From: Richard Heyes [mailto:[EMAIL PROTECTED]
Sent: jeudi 20 décembre 2007 14:26
To: Daniel Brown
Cc: Stut; [EMAIL PROTECTED]; Zoltán Németh; PHP General List
Subject: Re: [PHP] Just to confirm...
> Bah! You're right, I changed it to just be an easter egg in the
> code. The original (now commented out) was:
> <?
> if(stristr($_SERVER['HTTP_USER_AGENT'],"msie")) {
> die("No friend of Internet Exploder is a friend of mine.");
> }
> ?>
>
> It initially started to try to stop cURL, wget, Lynx, and other
> automated clients from grabbing the content from the page. Again, I
> know that headers can be spoofed, but that's a different topic. I try
> to make a joke and Stut shoots me in the ass. ;-P
I've got to ask, why on earth would you want to do this? Robots and
things like wget I could understand more, but purposefully cutting out a
large chunk of your audience?
--
Richard Heyes
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software
that can cut the cost of online support
** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS **
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Anti-IE..
<?php
if(stristr($_SERVER['HTTP_USER_AGENT'],"msie")) {
ob_start();
header('HTTP/1.1 200 OK');
echo str_pad('',4096);
ob_flush();
flush();
sleep(20);
}
?>
an IE penalty, don't loose visitors, just frustrate them a little, never
know they may try firefox and see it works that bit faster :)
Xavier de Lapeyre wrote:
<?
if(stristr($_SERVER['HTTP_USER_AGENT'],"msie")) {
die("No friend of Internet Exploder is a friend of mine.");
}
?>
Lol!!! I need to implement that on ALL my sites ... XD!!
Xavier de Lapeyre
-----Original Message-----
From: Richard Heyes [mailto:[EMAIL PROTECTED]
Sent: jeudi 20 décembre 2007 14:26
To: Daniel Brown
Cc: Stut; [EMAIL PROTECTED]; Zoltán Németh; PHP General List
Subject: Re: [PHP] Just to confirm...
Bah! You're right, I changed it to just be an easter egg in the
code. The original (now commented out) was:
<?
if(stristr($_SERVER['HTTP_USER_AGENT'],"msie")) {
die("No friend of Internet Exploder is a friend of mine.");
}
?>
It initially started to try to stop cURL, wget, Lynx, and other
automated clients from grabbing the content from the page. Again, I
know that headers can be spoofed, but that's a different topic. I try
to make a joke and Stut shoots me in the ass. ;-P
I've got to ask, why on earth would you want to do this? Robots and
things like wget I could understand more, but purposefully cutting out a
large chunk of your audience?
--- End Message ---
--- Begin Message ---
With any code doing a basic socket functionality, the code that i gave in
the original post is suppossed to connect to a deamon, and get a message
from it , instead it "makes the deamon go crazy" in the sense that it starts
endless looping and loads the system resources up to max.
"Jim Lucas" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> well, since it is the php version, and this is a php list, why don't you
> show us your complete PHP
> source code instead of you C++ source.
>
> --
> 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
--- End Message ---