php-general Digest 15 Oct 2007 18:34:10 -0000 Issue 5074

Topics (messages 263206 through 263216):

Re: Classes - Dumb question
        263206 by: Jay Blanchard
        263207 by: Nathan Nobbe
        263215 by: tedd
        263216 by: Nathan Nobbe

please advise
        263208 by: Philip Thompson
        263209 by: Dare Williams

Re: HTML Parse Issue
        263210 by: Jim Lucas

Parsing Strings
        263211 by: Philip Thompson
        263212 by: Andrew Ballard
        263213 by: Richard Heyes
        263214 by: Philip Thompson

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 ---
[snip]
>With a class you can inherit all of the base class functionality 
>into a new customer type. You do not have to break open the base 
>class to add a case, you just have to create an extension class. 
>Documentation is unique to each class.

No matter what, you have to break something open to add code -- if 
nothing else, the script.
[/snip]

The base class would (should?) be contained in its own script space. For 
instance you might have the customer class in a file called class.customer.php. 
You do not have to open this script to add another class or extend this class, 
you would just add another file like class.customerCommercial.php that extends 
the customer class. Since autoload is available now 
(http://www.php.net/autoload) you would not even have to open the 'calling' 
script to add an include line.

--- End Message ---
--- Begin Message ---
On 10/15/07, Jay Blanchard <[EMAIL PROTECTED]> wrote:
>
> [snip]
> >With a class you can inherit all of the base class functionality
> >into a new customer type. You do not have to break open the base
> >class to add a case, you just have to create an extension class.
> >Documentation is unique to each class.
>
> No matter what, you have to break something open to add code -- if
> nothing else, the script.
> [/snip]
>
> The base class would (should?) be contained in its own script space. For
> instance you might have the customer class in a file called
> class.customer.php. You do not have to open this script to add another
> class or extend this class, you would just add another file like
> class.customerCommercial.php that extends the customer class. Since
> autoload is available now (http://www.php.net/autoload) you would not even
> have to open the 'calling' script to add an include line.
>

furthermore using a delegation technique like Stut demonstrated,
you may not even need to edit a file to instantiate the class and call a
method.

-nathan

--- End Message ---
--- Begin Message ---
At 5:42 AM -0500 10/15/07, Jay Blanchard wrote:
[snip]
With a class you can inherit all of the base class functionality
into a new customer type. You do not have to break open the base
class to add a case, you just have to create an extension class.
Documentation is unique to each class.

No matter what, you have to break something open to add code -- if
nothing else, the script.
[/snip]

The base class would (should?) be contained in its own script space. For instance you might have the customer class in a file called class.customer.php. You do not have to open this script to add another class or extend this class, you would just add another file like class.customerCommercial.php that extends the customer class. Since autoload is available now (http://www.php.net/autoload) you would not even have to open the 'calling' script to add an include line.

I understand the class concept. But, I am not familiar with autoload.

Stut also made mention of that, so I shall investigate post haste.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On 10/15/07, tedd <[EMAIL PROTECTED]> wrote:
>
> I understand the class concept. But, I am not familiar with autoload.
>
> Stut also made mention of that, so I shall investigate post haste.


__autoload is pretty tight; but if you dont want to have all your class
files in the same
directory, i suggest you implement something custom.
ive seen several implementations where class names basically have filesystem
paths
embedded in them; ugh..  i think thats what those buxa project guys are
doing, but im
not certain.
also, the __autoload() function has to be available for it to be called,
which means you
will have to include the file that defines it in every file that would use
it.  since my php
code is heavily oop; i just use the php.ini auto_prepend_file directive.
oh; btw, Tedd, autoload is for classes only; if you like what you see maybe
that will be
the excuse youve been looking for to get into oop w/ php :)

-nathan

--- End Message ---
--- Begin Message ---
Sorry... meant to send this to the list....

---------- Forwarded message ----------
From: Philip Thompson <[EMAIL PROTECTED]>
Date: Oct 15, 2007 9:47 AM
Subject: Re: [PHP] please advise
To: Louise Sanders <[EMAIL PROTECTED]>

On 10/15/07, Louise Sanders <[EMAIL PROTECTED]> wrote:
>
> Hi There
>
> I am totally new to PHP and have just tried installing it on my machine
> according to instructions on the php.net manual installation instructions
> page - http://www.php.net/manual/en/install.windows.manual.php
>
> I think I managed to do most steps but I have a few questions:
>
> Under the PHP file, I have icons for php, php-win and php-cgi.   If I
> double
> click on any one of them, it says - "Are you sure you want to run this
> software?"  I have Windows Vista - 32 bit operating system and have
> installed IIS7.  Which one would you recommend that I run? Then, how do I
> know that everything is installed properly?


Make sure you read the specific steps for installing on Windows (
http://www.php.net/manual/en/install.windows.manual.php) and IIS
(http://www.php.net/manual/en/install.windows.iis.php).
To get running with IIS (or any other web server), you need to verify that
your settings are correct and the web server knows that PHP actually exists
on the machine.

To verify that it's installed properly, put this file on your web server...

<?php echo "Hello World"; ?>

If you get "Hello World" (w/o quotes) on that page when you visit it, you
know it's working.


Under optional steps:
>
> How do I change the doc_root to point to the web servers document_root??
> This was an optional step but not sure how to do this? (sorry basic
> question!) and what extensions would you recommend that I install?


This is a php.ini file setting. Look for the line that says:

doc_root = <some location>

For a Windows installation, you will want it to look something like:

doc_root = C:\Inetpub\wwwroot

Of course, if you set your web server's document root to a different
location, you'll want to reflect that in this line.

I look forward to any advice!
>
> Many Thanks
>
> Louise
>
> (South Africa)



Good luck.

~Philip

--- End Message ---
--- Begin Message ---
Dear Pal,
   
  As a PHP Programmer, I will advice you to go for an Application called WAMP 
which is the combination of MS WINDOWS PLATFORM, APACHE WEBSERVER, MYSQL 
DATABASE and PHP as Language.  I have been working with this application and 
have used it in developing different applications on PHP platform.
   
  You can get WAMP(WINDOWS,APACHE,MYSQL,PHP) from the following link with the 
related docs on how to use and operate it very well.
  WAMP links:
  www.wampserver.com/en/download.php
  en.wikipedia.org/wiki/WAMP
  www.puremango.co.uk/cm_wamp_97.php
   
  If you need any other asssitance, do not hesistate to Contact me.
  Williams Dare


       
---------------------------------
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, 
photos & more. 

--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
I am having a issue parsing an html file.
I want to pull all the data between two html tags.

Problem I am having is that no matter what I try  I can pull either tag or
both but not the data in between.

<div class="record" id="one">

                <div class="rideon">

                                <h2>

                                                <span>Welcome to
Rideon</span>

                                </h2>

                </div>

</div>

</div class="record" id="one">

function datamatch($document)

{

                preg_match_all('/<div class="record" [^<>]*>(.*)/<\/div
class="record" [^<>]*>/i',$document,$elements);

$match = implode("\r\n",$elements[0]);

return $match;

}

This should return the following

<div class="record" id="one">

                <div class="rideon">

                                <h2>

                                                <span>Welcome to
Rideon</span>

                                </h2>

                </div>

</div>

</div class="record" id="one">



<plaintext><?php

$data = '

<div class="record" id="one"><div class="rideon"><h2><span>Welcome to Rideon 
#1</span></h2></div></div>
<div class="record" id="two"><div class="rideon"><h2><span>Welcome to Rideon 
#2</span></h2></div></div>
<div class="record" id="three"><div class="rideon"><h2><span>Welcome to Rideon #3</span></h2></div></div>
<div class="record" id="four"><div class="rideon"><h2><span>Welcome to Rideon 
#4</span></h2></div></div>

';

if ( preg_match_all('!<div class="record" id="([^"]+)"><div class="rideon"><h2><span>([^<]+)</span></h2></div></div>!', $data, $matches, PREG_SET_ORDER) ) {
        print_r($matches);
} else {
        echo 'Could not match anything.';
}



--
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 ---
--- Begin Message ---
Hi.

Before I try and reinvent the wheel, I thought I'd query the list. I want to
take this string:

thisIsAStringIHave

and turn it into:

This Is A String I Have

Essentially, I want to capitalize the first letter (ucfirst) and then put a
space in front of each uppercase letter. I didn't find a PHP function that
did this (but maybe I didn't look diligently enough). My idea to accomplish
this is to create an array of capital letters. Then iterate through each
letter in the string. If a letter in the string matches a letter in the
array of capital letters, replace that letter with a space + that letter. Is
there a better way than brute-forcing this?? =D

Thanks in advance,
~Philip

--- End Message ---
--- Begin Message ---
On 10/15/07, Philip Thompson <[EMAIL PROTECTED]> wrote:
> Hi.
>
> Before I try and reinvent the wheel, I thought I'd query the list. I want to
> take this string:
>
> thisIsAStringIHave
>
> and turn it into:
>
> This Is A String I Have
>
> Essentially, I want to capitalize the first letter (ucfirst) and then put a
> space in front of each uppercase letter. I didn't find a PHP function that
> did this (but maybe I didn't look diligently enough).

How about this?

<?php

$string = 'thisIsAStringIHave';

$x = ucwords(preg_replace('/([A-Z])/', ' \\1', $string));

echo $x;
?>

--- End Message ---
--- Begin Message ---
Philip Thompson wrote:
> ...

<?php
    $str = 'thisIsAStringIHave';

    echo ucfirst(preg_replace('/([A-Z])/', ' $1', $str));
?>

HTH

--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

--- End Message ---
--- Begin Message ---
On 10/15/07, Richard Heyes <[EMAIL PROTECTED]> wrote:
>
> Philip Thompson wrote:
> > ...
>
> <?php
>      $str = 'thisIsAStringIHave';
>
>      echo ucfirst(preg_replace('/([A-Z])/', ' $1', $str));
> ?>
>
> HTH


Ha! I knew there was a much easier way. My brain is still not working this
Monday morning........ need... more... caf... feine........

Thanks!!
~Philip

--- End Message ---

Reply via email to