php-general Digest 28 May 2004 03:16:24 -0000 Issue 2788
Topics (messages 187049 through 187084):
Re: imagejpeg
187049 by: Chris Hayes
Re: Server Push
187050 by: jon
Keep PHP variable values between script calls - XML RPC
187051 by: Santiago Peirano
187053 by: Matt Matijevich
187055 by: Jay Blanchard
187058 by: Santiago Peirano
187067 by: Jason Barnett
187068 by: Jason Barnett
187084 by: Lance Lovette
ISSET problem with Form
187052 by: Tom Chubb
187054 by: Jay Blanchard
187056 by: Jay Blanchard
Self Testing PHP Code... Is it possible or practical??
187057 by: Adam Reiswig
187060 by: Greg Donald
handle E_STRICT with own error handler
187059 by: Bert Slagter
187070 by: Jason Barnett
187079 by: Bert Slagter
187080 by: Curt Zirzow
Re: How to check for a $_GET without throwing a Notice?
187061 by: Justin Patrin
Regular expression question
187062 by: Dan Phiffer
187071 by: Jason Barnett
187076 by: Rob Ellis
187081 by: Justin Patrin
Re: can myapp.exe run on Win ce or pocket pc?
187063 by: Jason Barnett
Re: Getting the name of the Class
187064 by: Jason Barnett
Re: Putting an image or logo on another image.
187065 by: Jason Barnett
Re: Changing environment variables ? (stupid question)
187066 by: Jason Barnett
include and require
187069 by: Lieve Vissenaeken
187072 by: php chucker
187073 by: Chris W. Parker
187074 by: Michal Migurski
array key starting with digit ending with string
187075 by: Larry Brown
187077 by: Matt Matijevich
187078 by: Matt Matijevich
Aspect Oriented Programming & PHP
187082 by: Lauzon, Michael
187083 by: Manuel Lemos
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 ---
At 15:10 27-5-04, you wrote:
I'm trying to create thumbnails for my images and everything seems to
work correctly except for trying to save them. I've tried outputting
directly with imagejpeg($im) and that works, but when trying
imagejpeg($im, "new.jpeg") it does not create a new image in the current
directory. I even tried changing the ownership of the script to root to
see if my permissions were screwed up but that didn't work. Here's my
function:
* I'm sure you have a writable directory
* I hope you are not trying to overwrite an existing image file that is not
writable
* maybe try to use the full path, check the manual to see whether they do
that. hint: use document_root to get the path
--- End Message ---
--- Begin Message ---
I used to work for a fairly major chat site that used software by iChat
to push slides -- and I'll be darned if I could figure out how they did
it. Some weird quirk of HTTP, I'd think.
Anyway -- getting a basic socket server up in running in the language of
your choice and using something like flash as a front-end is actually
not that hard. It seems to me that, in a lot of cases, PHP is the wrong
tool for the job when there are others out there that do it really well.
-- jon
George Lantz wrote:
I am just looking for some different techniques on how server push is
done on PHP:
I am fascinated by the PHP Live! Support Solution
(http://www.phplivesupport.com). I would like to try to replicate this
functionality just to see how it works and maybe use it on my own
website. Does anyone know how they accomplished server push and real
time chat?
I am aware or some different techniques such as <meta> refreshing (which
is really more client pull). I highly doubt this is how they
accomplished this. There is also sockets, which opens a possible
security concern, so I doubt they use that either.
I was thinking of using web service based on nuSOAP that simply checks
the database for new "messages". That closes the port because it is a
web service. But can this be done? Is there anyone that is familiar with
what method was used for real time chat/server Push? ESPECIALLY in PHP
Live!? I would really like to here some different thoughts and
techniques.
I have looked at some open source versions, but the ones I looked at all
used <meta> refresh. (They where also very slow).
Thanks everyone!
-George-
--- End Message ---
--- Begin Message ---
Ok, here we go.
I would like to implement an XML-RPC server (a script of course) that
keeps the value of certain variables between the different invocations
of the script.
I think that it should be possible, but I don’t know where to start
(none of the search in internet gave me a starting point).
Thanks in advance
Santiago
--- End Message ---
--- Begin Message ---
[snip]
I would like to implement an XML-RPC server (a script of course) that
keeps the value of certain variables between the different invocations
of the script.
[/snip]
Could you store them in a file? Maybe a database.
--- End Message ---
--- Begin Message ---
[snip]
Ok, here we go.
I would like to implement an XML-RPC server (a script of course) that
keeps the value of certain variables between the different invocations
of the script.
I think that it should be possible, but I don't know where to start
(none of the search in internet gave me a starting point).
[/snip]
Write the values of the variables out to a file to be read on the next
iteration of the script's usage.
--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
[snip]
Ok, here we go.
I would like to implement an XML-RPC server (a script of course) that
keeps the value of certain variables between the different invocations
of the script.
I think that it should be possible, but I don't know where to start
(none of the search in internet gave me a starting point).
[/snip]
Write the values of the variables out to a file to be read on the next
iteration of the script's usage.
You are right, but I need to implement a solution that avoids accessing
to disk.
The context under which I’m running now has not a huge database, but it
increments it’s size quite fast.
I must say that for that reason is that “many many updates” are made.
Also when one user gets a page much information should be shown.
The “good thing” is that this (shown) info does not need to be 100%
accurate (I can show information that is 15 minutes old without problem).
I would like to have this kind of intermediate PHP process in order to
serve these requests of information instead of accessing the database to
collect it (as far as I’m experiencing some disk bottlenecks).
Then the PHP process each "n" minutes or "m" requests refreshes the info
and present it on demand.
Here the reason for trying to implement this """layer""" (if it is
possible, +-easy and/or fast)
Thx again
Santiago
--- End Message ---
--- Begin Message ---
Sounds like a pretty run-of-the-mill storage issue; or did you want to
save XML messages? In any case, storing the information in a session is
probably the easiest and most straightforward way to do this. Or store
the information in a database.
Jason
--- End Message ---
--- Begin Message ---
If you're trying to prevent hitting the database then just cache the
page result and store it as a temporary html file. Then serve the
temporary file whenever people visit (and update every 15 minutes).
Jason
--- End Message ---
--- Begin Message ---
If you only need to persist a handful of request-agnostic variables you may
be able to make use of an extension I wrote. Note that it doesn't work under
Windows and I haven't tested it under PHP 4.3.x.
http://pwee.sourceforge.net/
Lance
> -----Original Message-----
> From: Santiago Peirano [mailto:[EMAIL PROTECTED]
> Sent: Thursday, May 27, 2004 11:17 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Keep PHP variable values between script calls - XML RPC
>
> Ok, here we go.
> I would like to implement an XML-RPC server (a script of course) that
> keeps the value of certain variables between the different
> invocations
> of the script.
>
> I think that it should be possible, but I don't know where to start
> (none of the search in internet gave me a starting point).
>
> Thanks in advance
>
> Santiago
--- End Message ---
--- Begin Message ---
If you use ISSET together with a hidden field when posting a form to itself
to enter a second-state, is there a way of using it again to get to a
third-state.
Basically, I'm trying to convert a 3 file script into a single file and
first I check to see if it's been submitted and then using ELSE I echo out
the second form. But how do I use isset again?
Do I need to unset the variable from the first stage of the form? If so, how
do I do this and prevent the form going back to the first form state?
I've had the script working with two states but can't get the third state
working!!!
Any help or alternative ideas much appreciated as this is causing me a
serious headache!!!
--- End Message ---
--- Begin Message ---
[snip]
I've had the script working with two states but can't get the third
state
working!!!
Any help or alternative ideas much appreciated as this is causing me a
serious headache!!!
[/snip]
Sessions would be a better way to handle this.
--- End Message ---
--- Begin Message ---
[snip]
I'm new to PHP, so how would I go about using sessions?
I assume one needs to update _SESSION['name'] = $name; with the state of
the
form and then use IF ?
Then I'm stuck again!
[/snip]
start here http://www.php.net/session
P.S. Always reply to the list, you may not get a response. Your e-mail
was redirected to my SPAM folder as an unknown. I just happened to see
it when looking for something else someone swore they sent me.
--- End Message ---
--- Begin Message ---
Hello all. I have been reading much lately about the wonders of writing
self testing code for java, perl and others. Is this a feasible task to
accomplish in PHP? I have googled every search I can think of and there
just does not appear to be any information regarding self testing php
out there. Thanks for any pointers, ideas, advice or help you may have.
-Adam R.
--- End Message ---
--- Begin Message ---
> Hello all. I have been reading much lately about the wonders of
writing
> self testing code for java, perl and others. Is this a feasible task
to
> accomplish in PHP? I have googled every search I can think of and
there
> just does not appear to be any information regarding self testing php
> out there. Thanks for any pointers, ideas, advice or help you may
have.
You can use assert() for simple debugging.
http://php.net/assert
There's also PHPUnit2 for bigger stuff.
http://pear.php.net/package/PHPUnit2
--
Greg Donald
http://destiney.com/
--- End Message ---
--- Begin Message ---
Hi,
I tried to use my own error handler to handle all non-fatal errors. But
to my surprise it seems to be impossible to handle E_STRICT level
notices. I don't know whether this is by design, not yet implemented or
a know bug that I overlooked - but it seems rather strange :).
To reproduce:
- create your own error handler
- set error_reporting to 0
- generate a E_STRICT notice, for example by using var $x as a class member.
Your error handler won't give a sound!
Anyone an idea?
Bert
--- End Message ---
--- Begin Message ---
Bert Slagter wrote:
Hi,
I tried to use my own error handler to handle all non-fatal errors. But
to my surprise it seems to be impossible to handle E_STRICT level
notices. I don't know whether this is by design, not yet implemented or
a know bug that I overlooked - but it seems rather strange :).
To reproduce:
- create your own error handler
- set error_reporting to 0
If you set error_reporting to 0, then why should you expect to have any
errors reported? You'd need error_reporting(2048) to just see those
errors (assuming you're using PHP5).
http://www.php.net/errorfunc
--- End Message ---
--- Begin Message ---
Jason,
Please read my question a bit better :).
PHP indeed does report the E_STRICT notices fine, that's not my problem.
I know how error handling in PHP works :).
But I have my own error handler (see: set_error_handler()) and handle
all notices and warnings myself (and all other E_USER_* of course). And
I was wondering why errors of the level E_STRICT don't make it to my
custom error handler function, in contrast to for example E_NOTICE.
Didn't expect to have to explain this here :(.
Bert
Jason Barnett wrote:
Bert Slagter wrote:
Hi,
I tried to use my own error handler to handle all non-fatal errors.
But to my surprise it seems to be impossible to handle E_STRICT level
notices. I don't know whether this is by design, not yet implemented
or a know bug that I overlooked - but it seems rather strange :).
To reproduce:
- create your own error handler
- set error_reporting to 0
If you set error_reporting to 0, then why should you expect to have any
errors reported? You'd need error_reporting(2048) to just see those
errors (assuming you're using PHP5).
http://www.php.net/errorfunc
--- End Message ---
--- Begin Message ---
* Thus wrote Bert Slagter ([EMAIL PROTECTED]):
> Hi,
>
> I tried to use my own error handler to handle all non-fatal errors. But
> to my surprise it seems to be impossible to handle E_STRICT level
> notices. I don't know whether this is by design, not yet implemented or
> a know bug that I overlooked - but it seems rather strange :).
>
> To reproduce:
> - create your own error handler
> - set error_reporting to 0
> - generate a E_STRICT notice, for example by using var $x as a class member.
var $x, E_STRICT error occures at compile time so it wont be able
to be caught.
On the otherhand, dl() throws a E_STRICT at runtime but the error
handler still doesn't get called.
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
--- End Message ---
--- Begin Message ---
Brian Dunning wrote:
How do I check for the presence of an optional $_GET param without
throwing a "Notice: Undefined index" when the param is not present?
Tried all three of these, they all produce the Notice when the param is
not passed:
if ($_GET['id'])
if ($_GET['id'] != "")
if (isset $_GET['id'])
isset should *not* be throwing a notice, that's what it's for. Try using
parenthesis.
if(isset($_GET['id']))
--
paperCrane <Justin Patrin>
--- End Message ---
--- Begin Message ---
So I'm trying to implement a simple wiki-like syntax for hyperlinking.
Basically I want to match stuff like [this], where the word 'this' gets
turned into a hyperlink. I have that working, but I want to be able to
escape the opening bracket, so that it's possible to do \[that] without
having it match as a link. Here's what I've got:
// Matches fine, but without escaping
$pattern = "
/
\[ # Open bracket
([^\]]+?) # Text, including whitespace
\] # Close bracket
/x
";
// Throws an unmatched bracket warning
$pattern = "
/
[^\\] # Don't match if a backslash precedes
\[ # Open bracket
([^\]]+?) # Text, including whitespace
\] # Close bracket
/x
";
// Ignores escaping: \[example] still matches
$pattern = "
/
[^\\\] # Don't match if a backslash precedes
\[ # Open bracket
([^\]]+?) # Text, including whitespace
\] # Close bracket
/x
";
Nothing seems to change if I keep adding backslashes to that first
matching thingy (i.e. the escaping still doesn't work). Any ideas?
Thanks much,
-Dan
--- End Message ---
--- Begin Message ---
This should work:
^\\ # Don't match if a backslash precedes
\[ # Open bracket
([^\]]+?) # Text, including whitespace
\] # Close bracket
By the way, using a tool called The Regex Coach I solved your problem in
about 10 seconds. For those having regex problems you might be
interested in this link, I have found this tool invaluable:
http://www.weitz.de/regex-coach/#install
--- End Message ---
--- Begin Message ---
On Thu, May 27, 2004 at 09:59:05AM -0700, Dan Phiffer wrote:
> So I'm trying to implement a simple wiki-like syntax for hyperlinking.
> Basically I want to match stuff like [this], where the word 'this' gets
> turned into a hyperlink. I have that working, but I want to be able to
> escape the opening bracket, so that it's possible to do \[that] without
> having it match as a link. Here's what I've got:
>
> // Matches fine, but without escaping
> $pattern = "
> /
> \[ # Open bracket
> ([^\]]+?) # Text, including whitespace
> \] # Close bracket
> /x
> ";
>
> // Throws an unmatched bracket warning
> $pattern = "
> /
> [^\\] # Don't match if a backslash precedes
> \[ # Open bracket
> ([^\]]+?) # Text, including whitespace
> \] # Close bracket
> /x
> ";
>
> // Ignores escaping: \[example] still matches
> $pattern = "
> /
> [^\\\] # Don't match if a backslash precedes
> \[ # Open bracket
> ([^\]]+?) # Text, including whitespace
> \] # Close bracket
> /x
> ";
>
> Nothing seems to change if I keep adding backslashes to that first
> matching thingy (i.e. the escaping still doesn't work). Any ideas?
>
Try negative lookbehinds...
$pattern = '
/
(?<!\\\\) \[ # open [ not preceded by a backslash
(.*?) # ungreedy match anything
(?<!\\\\) \] # close ] not preceded by a backslash
/x
';
- Rob
--- End Message ---
--- Begin Message ---
Rob Ellis wrote:
On Thu, May 27, 2004 at 09:59:05AM -0700, Dan Phiffer wrote:
So I'm trying to implement a simple wiki-like syntax for hyperlinking.
Basically I want to match stuff like [this], where the word 'this' gets
turned into a hyperlink. I have that working, but I want to be able to
escape the opening bracket, so that it's possible to do \[that] without
having it match as a link. Here's what I've got:
// Matches fine, but without escaping
$pattern = "
/
\[ # Open bracket
([^\]]+?) # Text, including whitespace
\] # Close bracket
/x
";
// Throws an unmatched bracket warning
$pattern = "
/
[^\\] # Don't match if a backslash precedes
\[ # Open bracket
([^\]]+?) # Text, including whitespace
\] # Close bracket
/x
";
// Ignores escaping: \[example] still matches
$pattern = "
/
[^\\\] # Don't match if a backslash precedes
\[ # Open bracket
([^\]]+?) # Text, including whitespace
\] # Close bracket
/x
";
Nothing seems to change if I keep adding backslashes to that first
matching thingy (i.e. the escaping still doesn't work). Any ideas?
Try negative lookbehinds...
$pattern = '
/
(?<!\\\\) \[ # open [ not preceded by a backslash
(.*?) # ungreedy match anything
(?<!\\\\) \] # close ] not preceded by a backslash
/x
';
- Rob
BTW, instead of un-greedy maych anything (.*?) You could use a negative
group....of course to deal with \] as well you have to do alittle more:
([^\]]|[\\\\\]])*
--
paperCrane <Justin Patrin>
--- End Message ---
--- Begin Message ---
Shelby wrote:
Hi,
I would like to develope a desktop application using PHP.
I was wondering can the .exe program run on Win CE/Pocket PC?
Please don't spam the list, we saw the message the first time. Well in
order to run the application on a pocket PC you'd need a PHP binary for
your specific platform (I don't know if there are any already out there,
but I think you can build it from source yourself if need be). Also,
you'll need PHP-GTK (PHP-GTK2 is supposed to be for PHP5, not sure about
the release date for that though).
Jason
--- End Message ---
--- Begin Message ---
Since you're invoking this as a static method the only solution that
comes to mind is to use the PHP5 builtin class Reflection_Method and/or
Refelction_Class. Perhaps something like:
<?php
Class Test {
function Test() {
echo 'Test';
}
}
Class MyClass extends Test {
function Debug() {
print 'Hello MyClass';
}
}
$reflection = new Reflection_Method('MyClass', 'Test');
echo "The declaring class is: " . $reflection->getDeclaringClass()->name;
?>
For a good overview of what you can do with Reflection_Method, see:
http://sitten-polizei.de/php/reflection_api/docs/language.reflection.class.reflection_method.html
--- End Message ---
--- Begin Message ---
I haven't done image manipulation much, but for good source code on how
to do it look at JpGraph. It creates image canvases and draws graph
images on top of a canvas, it's really quite impressive.
http://www.aditus.nu/jpgraph/
--- End Message ---
--- Begin Message ---
Oooh, wish you'd said Windows, I coulda given you a walkthru there. The
environment variable that you want to set cannot (AFAIK) be changed by
Apache. You'll need to change the variable in Solaris itself.
So sayeth google:
http://docs.sun.com/db/doc/806-7612/6jgfmsvrt?a=view
--- End Message ---
--- Begin Message ---
Hi,
Can anyone help me with this one:
Is there a difference between "include()" and "require()" ?
Thanks for helping...
--- End Message ---
--- Begin Message ---
include() will output warning message and the script continues
require() will output error message and will halt the script
-----Original Message-----
From: Lieve Vissenaeken [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 27, 2004 2:05 PM
To: [EMAIL PROTECTED]
Subject: [PHP] include and require
Hi,
Can anyone help me with this one:
Is there a difference between "include()" and "require()" ?
Thanks for helping...
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Lieve Vissenaeken <mailto:[EMAIL PROTECTED]>
on Thursday, May 27, 2004 11:05 AM said:
> Can anyone help me with this one:
> Is there a difference between "include()" and "require()" ?
yes i can help you with it. go to www.php.net and search for "include".
you will then find the answer you are looking for. the php website is
really great! fo sho.
chris.
--- End Message ---
--- Begin Message ---
> Can anyone help me with this one:
> Is there a difference between "include()" and "require()" ?
http://php.net/require
http://php.net/include
require() and include() are identical in every way except how they
handle failure. include() produces a Warning while require()
results in a Fatal Error. In other words, don't hesitate to use
require() if you want a missing file to halt processing of the
page. include() does not behave this way, the script will continue
regardless. Be sure to have an appropriate include_path setting as
well.
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
--- End Message ---
--- Begin Message ---
I have an unusual situation where I have to communicate with an MS based
soap server. They have named one of their variables with a name leading
with a 1 such as 1variable. Nusoap loads the variable descriptions from the
wsdl document and compares the variable names I am trying to send with the
ones listed in the wsdl. In this process my sent to the function is
something like $data =
array('thisvar'=>$myFirstVar,'thatvar'=>$mySecondVar,'1othervar'=>$myLastVar
). Later when the variable names are cycled through on a loop the following
test is used...
if($data[$currentVarNameInCycle])
{
do something
}
Is there some way force the recognition of the key when it leads with a
digit?
--- End Message ---
--- Begin Message ---
[snip]
if($data[$currentVarNameInCycle])
{
do something
}
Is there some way force the recognition of the key when it leads with
a
digit?
[/snip]
not sure I follow 100% but you could use a regular expression to
detemine if it starts with a string.
if (preg_match('/^\d/',$array_key)) {
//do something
}
--- End Message ---
--- Begin Message ---
[snip]
not sure I follow 100% but you could use a regular expression to
detemine if it starts with a string.
if (preg_match('/^\d/',$array_key)) {
//do something
}
[/snip]
I mean starts with a digit, sorry for 2 emails. I should proofread.
--- End Message ---
--- Begin Message ---
Since PHP5 is going to feature OOP (Object Oriented Programming), will that mean PHP6
will feature AOP (Aspect Oriented Programming)...so far it seems AOP is only being
used for Java at the moment; but hopefully general programming and scripting languages
will start using them as well?!
Michael Lauzon, Founder
The Quill Society
http://www.quillsociety.org/
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Hello,
On 12/31/1969 09:00 PM, Michael Lauzon wrote:
Since PHP5 is going to feature OOP (Object Oriented Programming),
will that mean PHP6 will feature AOP (Aspect Oriented
Programming)...so far it seems AOP is only being used for Java at the
moment; but hopefully general programming and scripting languages
will start using them as well?!
I don't know what do you think OOP is but PHP supports it since PHP 3.
AOP is not a feature of any language but rather an artifact to add or
remove code that implements certain aspects. This usually requires a
compiler or a code processing tool to enable the aspects you are
interested. There is nothing in Java that makes this possible that would
not be possible in PHP.
As a matter of fact there is an Aspect Oriented Programming tool named
Metastorage that generates DAO (Data Access Object) classes that lets
you control which aspects you want to build into your DAO classes. For
instance, if you do want a function in the generated classes to delete
objects, you have to explicitly request it. Otherwise the class will not
feature that aspect. This leads to much more optimized code that does
not feature aspects that are not needed.
This tool generates code that runs on PHP 4 or better. You may find more
about it here:
http://www.meta-language.net/metastorage.html
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--- End Message ---