php-general Digest 3 Dec 2004 10:37:02 -0000 Issue 3148

Topics (messages 203393 through 203411):

Re: $this - >
        203393 by: Matthew Weier O'Phinney
        203408 by: Klaus Reimer

Strange character conversion when converting XML by XSLT in PHP
        203394 by: Age Bosma
        203395 by: John Holmes
        203400 by: Richard Lynch

Re: Too many DELETE statements
        203396 by: Richard Lynch
        203399 by: Richard Lynch

Re: Working with Dates
        203397 by: Richard Lynch

Re: How to Add a Module
        203398 by: Richard Lynch

Apache 2 survey
        203401 by: Bart Baenisch

Mining protection / security code confirmation
        203402 by: Ho!Tech Guy
        203411 by: Jordi Canals

Re: Sessions: Basic Information
        203403 by: Peter Lauri

Need Help
        203404 by: suneel
        203405 by: GH
        203406 by: Peter Lauri
        203407 by: Thomas Goyne

Re: Very fresh to php
        203409 by: Zareef Ahmed

Re: Custom Open Tags
        203410 by: Red Wingate

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 ---
* R. Van Tassel <[EMAIL PROTECTED]>:
> ------=_NextPart_000_0039_01C4D88C.AECDCB00
> Content-Type: text/plain;
>       charset="us-ascii"
> Content-Transfer-Encoding: 7bit
>
> Can someone please point me to the php documentation where it explains
>
> $this - > 
>
> What is the symbol "- >" and is $this something only used in classes?
>
> I can't find any information that explains this specifically but see it used
> everywhere.

It's in http://php.net/oop and/or http://php.net/oop5 (php5). $this is a
special variable used within methods of classes to indicate the current
object instance. The '->' notation is used to access object properties
and methods.

-- 
Matthew Weier O'Phinney           | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org

--- End Message ---
--- Begin Message --- R. Van Tassel wrote:
Can someone please point me to the php documentation where it explains
$this - >

1. It must be "$this->" and not "$this - >".

2. Documentation can be found here:

        http://de.php.net/manual/en/language.oop.php


What is the symbol "- >" and is $this something only used in classes?

Yes. Inside a method you can use "$this" to reference the current object in which the method was called. The "->" operator is not specific to "$this". It is generelly used to call methods or access properties of an object.

--- End Message ---
--- Begin Message --- I'm converting, or at least trying, one XML file to another XML format using XSLT parsing it with PHP.

I'm using a lot of characters in the following style "& #34;", "& #42;", etc. (without the space, added now the prevent any conversion in this e-mail) in the XML file and I would like to keep it that way. PHP is converting every string like these to e.g. "&qout;" or "*". What can be done to prevent this conversion?

As far as I understand this is default behaviour of the parser and can not be prevented. Personally I consider this a bug because what if I just want to use "& #34;" (without the space) as a normal string value? The parser shouldn't touch it at all.

Can someone enlighten me a bit more on this one? :-)

Cheers,

Age
--- End Message ---
--- Begin Message --- Age Bosma wrote:
I'm converting, or at least trying, one XML file to another XML format using XSLT parsing it with PHP.

I'm using a lot of characters in the following style "& #34;", "& #42;", etc. (without the space, added now the prevent any conversion in this e-mail) in the XML file and I would like to keep it that way. PHP is converting every string like these to e.g. "&qout;" or "*". What can be done to prevent this conversion?

As far as I understand this is default behaviour of the parser and can not be prevented. Personally I consider this a bug because what if I just want to use "& #34;" (without the space) as a normal string value? The parser shouldn't touch it at all.

Can someone enlighten me a bit more on this one? :-)

If you want a literal &#34; in your data, then you should have &amp;#34;, iirc. Maybe you could run the data through a preparser to match "&#xx;" patterns and convert the & to &amp; ??


--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Age Bosma wrote:
> I'm converting, or at least trying, one XML file to another XML format
> using XSLT parsing it with PHP.
>
> I'm using a lot of characters in the following style "& #34;", "& #42;",
> etc. (without the space, added now the prevent any conversion in this
> e-mail) in the XML file and I would like to keep it that way. PHP is
> converting every string like these to e.g. "&qout;" or "*". What can be
> done to prevent this conversion?
>
> As far as I understand this is default behaviour of the parser and can
> not be prevented. Personally I consider this a bug because what if I
> just want to use "& #34;" (without the space) as a normal string value?
> The parser shouldn't touch it at all.
>
> Can someone enlighten me a bit more on this one? :-)

I avoid XML as much as possible, as the biggest bugaboo since Y2K, but,
worst-case scenario.

You should be able to do a http://php.net/str_replace in some judicious
place to un-do the places where the XML parser messed up...

Of course, if you've got & quot; in there in some places, and you want
THAT left alone, you're in trouble...

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

--- End Message ---
--- Begin Message ---
David Dickson wrote:
> Richard Lynch wrote:
>> Plus you are unlink-ing 10 files.  That's probably the real problem.
>>
>> You'd have to write some timing code to be sure, though, as a slow
>> database server and a very fast hard drive could be involved.
>>
>> Here are some things you could do to speed it up, assuming you don't
>> want
>> the ON DELETE CASCADE option, or if your database doesn't provide that
>> option.
>
> You should do this (even if you don't want to) because it is good
> design. If when a member is deleted you want all associated tables to
> also delete this member information then you should set up your foreign
> keys properly.

But you may not want this to *ALWAYS* happen in your business logic.

I don't know enough about the application he's writing to say for sure
either way.

You'd think that you wouldn't want related records hanging around when
deleting a user, but sometimes one does.  Just depends on the application.

> Something else you could do is to build one big rm statement and run it
> in the background. This would save you building a cron job which
> sometimes isn't possible depending on the hosting arrangement.
>
> <?php
>
> $Remove = "rm $ImageLocation1; rm $ImagLocation2; rm $ImageLocation3";
> exec("nohop $Remove > /dev/null 2>&1 &");

nohop?

Maybe you mean nohup?...

Or maybe I need to go read "man nohop"... :-)

I've found inconsistent results with trying to fork in the shell from PHP
-- Again this may go back to earlier versions, but I don't know that this
will work for sure in all versions.

> Where the $ImageLocationx is the full path to the image you want to
> delete. The & at the end of the exec tells the command to run in the
> background, which means your script won't wait for the command to finish
> before continuing. The output redirection ( > /dev/null 2>&1) is also
> necessary to allow the script to continue. See the PHP documentation on
> exec for more details.

The downside is that it makes this difficult to debug.

Probably better to re-direct the errors *somewhere* so you have a chance
at debugging things when (not if, when) they break.

Though it probably takes care of whatever was messing me up back in the
day when I was trying to get exec() to fork.

I must say, though, I've found over time that setting up a cron job to
take care of this kind of stuff usually works better for me and the user
experience than exec/fork.

Even with the & to fork, exec is not all that fast, I don't think.

A quick insert to a small table so that a cron job can unlink (and delete
from the table) later works better/faster for me.  YMMV.

Just my opinions, of course.

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

--- End Message ---
--- Begin Message ---
Lordo wrote:
> Thanks guys. I delete 500 by 500 now and it takes like 20 seconds only. I
> am
> using the manual select where in method. It is great.
>
> Now for the files, OK I will use a cron. But can I change the way I get
> the
> file names? I mean instead of deleting the photo that is related to a
> deleted member, can I delete photos that were last accessed a year ago?

Sure.

Every Linux file has a file times recorded when it was last accessed, and
last had *anything* including permissions etc modified, and when it was
originally created.

But this might be real dangerous.  Somebody might have a photo they want
to keep that you are about to nuke...

Also be sure to read the caveat in the docs about system where fileatime
is NOT getting changed for performance reasons.

http://php.net/fileatime

You'd probably be better off to nuke the photos of the deleted users, and
then see where you really stand with out-dated/unused photos.

Might be a lot less than you think.

Another option is to write a shell script (or PHP) to find really HUGE
photos that goofballs have uploaded, or users who have *waaaay* too many
photos, and harass them individually.

It's usually the case that one or two users are clogging up 90% of your
resources when you start digging into this stuff. :-)

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

--- End Message ---
--- Begin Message ---
Robert Sossomon wrote:
> I have this code below that needs to display stuff depending on WHEN it
> is.  I
> am pretty sure it is something simple I have confused (again) but can't
> place my
> finger on it.  Anyone see the mistake?
>
>
> <?php
> $today = date("m-d-y");
> $early = date("m-d-y",mktime(0, 0, 0, 1, 14, 2005));
> $normal = date("m-d-y",mktime(0, 0, 0, 1, 31, 2005));
> if ($today <= $early) //also done with writing in "01-14-05"
> {
>   print "<tr><td>Pre-Conference</td><td>$12</td><td><input
> name=\"Pre-Conference\" type=\"radio\" value=\"Y\"></td></tr>";
>   print "<tr><td>Early Registration (thru 01-14-05)</td><td>$85<input
> name=\"Conference\" type=\"radio\" value=\"Early
> Registration\"></td></tr>";
>   print "<tr><td>Registration for Saturday Only (thru
> 01-14-05)</td><td>$65</td><td><input name=\"Conference\" type=\"radio\"
> value=\"Early Saturday Only\"></td></tr>";
> }
> else if ($today >= "01-15-05" || $today <= "01-31-05")

Make this be "elseif" (one word) or you'll some day confuse yourself when
you get nested if/else things going.

Also, you don't want || here, really...
You'd want && to say what you are trying to say.
Dates *WAY* in the future are bigger then 01-15-05, and so they never get
compared to 01-31-05 because you used ||.

At this point, you already *KNOW* that the date is larger than 01-14-05,
so the whole check about 01-15-05 is kinda pointless.

elseif ($today <= "01-31-05") {



A couple other notes.

If you're going to print() out more than a couple lines, just get out of
PHP.  It's going to be easier to maintain your HTML if you do.

Also, you might find this a more natural way to do things:

$today = time();
<?php
if ($today <= mktime(0, 0, 0, 1, 14, 2005){
  ?>
  Early Registration Stuff Here.
  <?php
}
elseif ($today <= mktime(0, 0, 0, 1, 31, 2005){
  ?>
  Normal Registratoin Stuff Here.
  <?php
}
else{
  ?>
  Tell them how great the event was here, and how they should get on the
  mailing list to sign up for next year!
  <?php
}

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

--- End Message ---
--- Begin Message ---
Nick Peters wrote:
> i currently have a apache and php installed perfectly on my box (slackware
> 10). However, i have the need to use mcrypt. I have mcrypt all compiled
> and
> installed, but how do i add the module to my php install? I have searched
> a
> few places on the net and i can't figure it out. Thanks in advance.

If you compiled from source, go back to your PHP source directory, and do:

./config.nice --with-mcrypt

This should copy all your old settings, which were stored in 'config.nice'
from the last time, but tack on --with-mcrypt for you this time.

If you installed from an RPM or whatever Slackware uses for package
management, then you have just stumbled across the main downfall of
packages:  Whomever makes the Slackware PHP package thinks you don't need
mcrypt and you are stuck with starting over compiling PHP from source to
get what you want.  Sorry.

PS While you are at it, you may want to breeze through the manual and see
if there's anything else you for sure want to play with in the next few
weeks, and install that too.

Buuuuuut, don't go hog-wild trying to add in a bunch of stuff you might
want "some day"  --  You'll drive yourself crazy trying to get it all
installed, and never get to it until you need to upgrade PHP anyway.  "I
been down that road before"

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

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

Please help me quantify the risk of Apache 2.x with PHP 5.x.

Thank you for making the time.

If I missed this on php.net or apache.org or somewhere else, 
please point me to the data.  There is other good survey 
info, but not the PHP 5/Apache 2 combo.

Reply to me directly and I'll summarize for the list by 
Monday, 6 December 2005.

If you are using PHP 5.x with Apache 2.x on Linux or Solaris -

what type of HW?  CPU(s?), RAM, Internet bandwidth
what Solaris level or Linux distro?
average % of HW gets used?  particularly CPU & bandwidth

If you tried Apache 2.x and had to switch to Apache 1.x, what 
were the symptoms?

Thank you for your time.

-Bart

--- End Message ---
--- Begin Message --- I have a classified ad section on my site which uses a privacy mail function so users don't have to make their email address public. Recently though, the site has been mined (I assume) and spam is being sent.

I was thinking that a "security code confirmation" type script would be good where the user has to enter the number shown in a graphic. Am I on the right track? If so, can anyone recommend a specific script?

Any advice would be gratefully received.
--- End Message ---
--- Begin Message ---
On Fri, 03 Dec 2004 09:43:10 +0800, Ho!Tech Guy <[EMAIL PROTECTED]> wrote:
> I have a classified ad section on my site which uses a privacy mail
> function so users don't have to make their email address public. Recently
> though, the site has been mined (I assume) and spam is being sent.
> 
> I was thinking that a "security code confirmation" type script would be
> good where the user has to enter the number shown in a graphic. Am I on the
> right track? If so, can anyone recommend a specific script?
>

I cannot recommend a specific script, but a good article and tutorial
from the Zend website:
http://www.zend.com/zend/tut/tutorial-mehmet1.php

Hope this helps,
Jordi.

--- End Message ---
--- Begin Message ---
Sessions will make you life easier if you are using cookies to control a web
session. http://th.php.net/manual/en/ref.session.php will give you most
information regarding this, together with some examples. Play around with
simple own examples and you will learn to work with sessions relativly fast.

/Peter


"Lordo" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> I have not yet worked with sessions and I don't know why I DO NOT WANT to
> understand it!! :)) I am a traditional ASPer and I am addicted to cookies.
> But I want to use sessions if they will make life easier for me.
>
> Can someone please direct me to an easy to understand resource with
working
> samples? Thanks.
>
> Lordo

--- End Message ---
--- Begin Message ---
Hi to all

            any one Could tell me any diffrence between <?php ?>  and <? ?>. 
And which one is better to use and in which situations.

Byeeeeee

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

They are the same... some servers might not have <? enabled... all the
demos I have seen and tutorials use <?PHP ?> That seems to be the
standard....



On Fri, 3 Dec 2004 09:32:34 +0530, suneel <[EMAIL PROTECTED]> wrote:
> Hi to all
> 
>            any one Could tell me any diffrence between <?php ?>  and <? ?>. 
> And which one is better to use and in which situations.
> 
> Byeeeeee
>

--- End Message ---
--- Begin Message ---
Use <?php ?> if you are implementing php. I think that you can predefine
what scriptlanguage to use, and therefore <? ?> can be used.

/Peter


"Suneel" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
Hi to all

            any one Could tell me any diffrence between <?php ?>  and <? ?>.
And which one is better to use and in which situations.

Byeeeeee

--- End Message ---
--- Begin Message --- On Fri, 3 Dec 2004 09:32:34 +0530, suneel <[EMAIL PROTECTED]> wrote:

Hi to all

any one Could tell me any diffrence between <?php ?> and <? ?>. And which one is better to use and in which situations.

Byeeeeee

<? ?> is the older syntax, and it can cause problems with xml (as the xml prolog uses <?). Unless you have a specific reason to use <? (and laziness isn't a good one) you should generally use <?php.


--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

http://www.smempire.org
--- End Message ---
--- Begin Message ---
Hi,

  Visit http://www.sitepoint.com/article/phps-creator-rasmus-lerdorf/39


Zareef ahmed 


-----Original Message-----
From: Reinhart Viane [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 01, 2004 8:09 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [PHP] Very fresh to php

I think it was Darth Moeder

"PHP, I am your mother, *heavely breathing*"

(for those who don't speak dutch: Vader is 'father' and Moeder is
'mother') 

-----Original Message-----
From: Santa [mailto:[EMAIL PROTECTED] 
Sent: woensdag 1 december 2004 9:29
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Very fresh to php


В сообщении от Среда 01 Декабрь 2004 07:45 suneel написал(a):
> Hi...guys,
>
>             I'm a new bee to php. Could any one tell me that who is 
> the father of php?
>
> take care guys,

and who is mother? 8)

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



Zareef Ahmed :: A PHP Developer in Delhi ( India )
Homepage :: http://www.zasaifi.com


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.802 / Virus Database: 545 - Release Date: 11/26/2004
 

--- End Message ---
--- Begin Message ---
Hi Sven,

i was in the need to allow <?php Tags within template-layers which caused
me some problems at first as i ran into the situation you described. I was
able to solve this problem quite well using this function:

/**
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Â*/
function ParsePHP ( $content ) {
ÂÂÂÂpreg_match_all(Â"#\<\?php(.*?)\?\>#sim"Â,Â$contentÂ,Â$source_partsÂ);
ÂÂÂÂforeachÂ(Â$source_parts[1]ÂASÂ$idÂ=>Â$php_sourceÂ)Â{
ÂÂÂÂÂÂÂÂob_start();Â
ÂÂÂÂÂÂÂÂeval(Âereg_replace(Â"\\$([a-zA-Z_][a-zA-Z0-9_]*)"Â,
"\$GLOBALS[\"\\1\"]" , $php_source ) );
ÂÂÂÂÂÂÂÂ$contentÂ=Âstr_replace(Â$source_parts[0][$id]Â,Âob_get_contents()Â,
$content );
ÂÂÂÂÂÂÂÂob_end_clean();
ÂÂÂÂ}

ÂÂÂÂreturnÂ$contentÂ;
}

Adding some minor changed would allow you to use custom opening and closing
tags (in fact you would just replace the <\?php with <\?xyz and would be
done.

I'm using the regular expression to replace
ÂÂ"\\$([a-zA-Z_][a-zA-Z0-9_]*)"Â
with
ÂÂ"\$GLOBALS[\"\\1\"]"
to make sure all variables are found as we are within the function's scoope
and not within the global one.

Maybe this helps some ppl.

-- red

> The only downside: No single quote (') is possible outside <?xyz ... ?>
> tags in the file included. This can of course be fixed, but only with a
> ridiculous amount of code. If only there was a way to do heredoc
> strings that DON'T parse variables (like in Perl).

--- End Message ---

Reply via email to