php-general Digest 31 Jul 2008 15:58:29 -0000 Issue 5599

Topics (messages 277512 through 277536):

Re: Web2.0 style tags - where to start?
        277512 by: Nitsan Bin-Nun
        277515 by: Jason Norwood-Young

Re: Using $_GET for POST
        277513 by: Nitsan Bin-Nun
        277514 by: Robert Cummings
        277524 by: Dan Shirah

Re: Creating new site
        277516 by: Raido
        277517 by: Raido
        277518 by: Jason Norwood-Young
        277530 by: Shawn McKenzie
        277534 by: Richard Heyes

Re: Get Remote-Image
        277519 by: Aschwin Wesselius
        277520 by: Richard Heyes
        277532 by: Shawn McKenzie
        277533 by: Shawn McKenzie

PHP email
        277521 by: Richard Heyes

Re: Back to Basics - Why Use Single Quotes?
        277522 by: Dan Shirah
        277523 by: Richard Heyes
        277525 by: Eric Butera
        277526 by: Eric Butera

upload file problem
        277527 by: Jignesh Thummar
        277528 by: Eric Butera
        277529 by: Jignesh Thummar

Re: accessing variables within objects
        277531 by: Philip Thompson

strange string evaluation
        277535 by: Marten Lehmann
        277536 by: Robert Cummings

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 ---
>From my experience with Codeigniter, thats one of the best php frameworks I
have ever seen.
It functionality is awesome, you can integrate your own modifications to the
IC core without any problems at all, for more confortable you even don't
have to use a template system (but I'm pretty sure that you can integrate
Smarty to IC) and write your template with a pseudo code, CI supports <?php
?> code inside your template!

Nitsan

2008/7/29 Jason Norwood-Young <[EMAIL PROTECTED]>

>
> On Mon, 2008-07-28 at 23:57 +0100, Paul Jinks wrote:
> > Jason Norwood-Young wrote:
> > > On Mon, 2008-07-28 at 14:48 +0100, Paul Jinks wrote:
> > >
> > >> I think my first post was ambiguous. What we're thinking of is to
> build a
> > >> site on which people can view videos with the option to add metadata
> to a
> > >> video after viewing it.
> > >>
> > >> We think that the content we have will be of wide interest to a lot of
> > >> people and the best way to index it is for users to 'tag' it
> themselves,
> > >> since it's hard for us to anticipate the uses that people may have for
> the
> > >> content.
> > >>
> > >
> > > How do you plan to have users enter the info? Through the Flash player,
> > > through some kinda Ajax form, through a form in a frame or just a
> static
> > > form?
> > >
> > > Also, would the tags be predefined by you (eg. genres like the ID3 tag
> > > genres) or would people be able to add their own tags?
> > >
> > > The way I'd do it would be to let the users enter the info through an
> > > Ajax form below the video, with suggestions popping up as they type.
> > > Then save it in a separate table (I assume all your vids are in their
> > > own table) with a link table between the vids table and the tags table
> > > (M2M relationship). This means that if the tag is already in there and
> > > linked to one vid, you don't replicate it for a second vid. It's also
> > > very easy to do lookups of similar items. I'd also add a weighting to
> > > the tags in the links table, maybe with the more people that add a
> > > specific tag, the more weight that tag gets.
> > >
> > > Also check out http://www.music-map.com/ as an example of showing
> > > similar music - you might even be able to plug into this data.
> > >
> > >
> > Hi Jason
> >
> > Hmm, food for thought. music-map is brilliant, though not what I'm
> > looking for graphically at the moment (was surprised to find Cesaria
> > Evora in close proximity to The Cardigans but I digress).
> >
> > What you describe is pretty much what I'm chasing, thanks and helps me
> > down the road, particularly with thinking about the database set up.
> > They 'only' problem is, my php/mysql skills are some way behind my
> > javascript/actionscript  knowhow (I'm pretty much a noob here);  what I
> > could use now is a how-to tutorial to give me some code to work off,
> > either online or in a book. If it ain't there, I can build from scratch
> > but it's going to mean a lot of calls for help! =)
> >
> > Many thanks
> >
> > Paul
>
> In that case, I suggest the following solution:
> 1. Download the unternet into your puter
> 2. Open the file called mysql.com
> 3. Read and learn
> 4. Open the file called php.net
> 5. Read and learn
> 6. Rinse and repeat
>
> In all seriousness, this is a nice, simple project to learn on. You want
> to look at different types of relationships in Sql (one-to-one,
> one-to-many and many-to-many) and learn a bit about basic DB
> architecture; make some tables and play with getting data in and out
> (get PHPMyAdmin to help you out); maybe use a nice simple framework like
> CodeIgniter to get you kick-started on the PHP.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Thu, 2008-07-31 at 06:28 +0200, Nitsan Bin-Nun wrote:
> From my experience with Codeigniter, thats one of the best php frameworks I
> have ever seen.
> It functionality is awesome, you can integrate your own modifications to the
> IC core without any problems at all, for more confortable you even don't
> have to use a template system (but I'm pretty sure that you can integrate
> Smarty to IC) and write your template with a pseudo code, CI supports <?php
> ?> code inside your template!

What I love about CodeIgniter is that, while some frameworks obfuscate
my thinking, CodeIgniter clarifies my thoughts, structure and overall
architecture. MVC programming is no longer some mysterious theoretical
entity - it just makes sense with CodeIgniter. Plus it doesn't tell you
how to do something - it just gives you the structure for you to decide
and do whatever you want. And it's so light I'd barely call it a
framework - more like a kick-start. I could wax lyrical about this all
day. Maybe I should write an ode...


--- End Message ---
--- Begin Message ---
Umm I suggest you try this code:

index.php:

<?php
$formContainer = <<<EOF
       <form ACTION="index.php?this=is&awsome=dont&you=think" METHOD="POST">
       <input type='text' name='check' value='' /><br />
       <input VALUE="submit" name='submitted' TYPE="submit"></form>
EOF;

if (!isset($_POST['submitted']))
   echo $formContainer;
else
{
   echo "<xmp>";
   var_dump($_GET);
   echo "\n\n\n";
   var_dump($_POST);
   echo '</xmp>';
   echo $formContainer;
}
?>

HTH,
Nitsan

2008/7/31 Robert Cummings <[EMAIL PROTECTED]>

> On Wed, 2008-07-30 at 22:18 -0400, Edward Diener wrote:
> > In handling an HTTP POST request I came across some PHP code, which I
> > need to modify for my own purposes, which has code like this:
> >
> > if ( ! (isset($_GET['xxxxx']) && $_GET['xxxxx'] == 20) )
> >     {
> >     // Do something by returning an error
> >     }
> >
> > Can this ever be correct when the form looks like:
> >
> >       <form ENCTYPE="multipart/form-data" ACTION="" METHOD="POST">
> >       <input NAME="SomeFile" TYPE="file">
> >       <input VALUE="submit" TYPE="submit"></form>
> >
> > ?
> >
> > Is the $_GET possibly being used to check for an 'xxxxx' parameter being
> > passed in the query part of the URL ?
> >
> > I am fairly new to PHP so I am trying to understand how $_GET differs
> > from $_POST. Thanks !
>
> Yes this can be correct. Since the above action is set to blank, the
> form will submit to the same page as that on which is is presented. As
> such, if any GET parameters were set in the URL, they will be
> re-presented upon submission along with any POSTed data.
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Thu, 2008-07-31 at 06:41 +0200, Nitsan Bin-Nun wrote:
> Umm I suggest you try this code:
> 
> index.php:
> 
> <?php
> $formContainer = <<<EOF
>        <form ACTION="index.php?this=is&awsome=dont&you=think" METHOD="POST">

Those ampersands should be appropriately marked up.

:B

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
>
> if ( ! (isset($_GET['xxxxx']) && $_GET['xxxxx'] == 20) )
>   {
>   // Do something by returning an error
>   }
>
> Can this ever be correct when the form looks like:
>
>        <form ENCTYPE="multipart/form-data" ACTION="" METHOD="POST">
>        <input NAME="SomeFile" TYPE="file">
>        <input VALUE="submit" TYPE="submit"></form>
>
> ?


I sometimes do things similar to this.  I normally use it when I am opening
a new page via a javascript function and want to pass several values to use
or check in the new page.

--- End Message ---
--- Begin Message --- I have investigated some frameworks.. Zend and Codeiginiter but I haven't done any testing/exercises. They seem to make things much more simple/faster yes...but I'm not sure how much time it will take to get know one of them(or CakePHP). And I haven't got into reading licences...I'm sure they have got licences that restricts something(or not ?) To be honest, I kinda hate all kind of licences. There are many pages info what I can and what I can't do...but I mostly like to do what I have and want to do. Also, inventing the wheel once, might give good experience or am I going slippery way ?



Shawn McKenzie wrote:
Micah Gersten wrote:
Depending on the size of the site, you might want to consider a PHP
framework to start with.  There's usually no point in reinventing the
wheel.  Someone mentioned CakePHP which utilizes MVC.  I'm looking into
porting my stuff to the Zend Framework which makes MVC optional, but has
a lot of functionality make available.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com


I too like CakePHP. I have coded in PHP for quite a while and understand OOP and OOP in PHP, however I don't really have any experience building sites or apps from scratch using OOP/MVC.

Cake or a framework makes it much quicker and easier. For those that need total freedom to do things the way they want but need some pre-built functionality to make it quicker, Zend seems to be the choice. I consider Zend to be more of a class library like PEAR only more consistant. For me, I had no habits/best practices or preferred way when I started with OOP/MVC so Cake was great. It has a certain structure and uses certain conventions and code generation which makes it very quick and easy. The main drawback is the docs.

-Shawn



Raido wrote:
Hi,

There are many sites explaining how to build new site etc but I'd like
to hear what You suggest. (about how to plan whole thing and how to
write separate parts which can be put together later)

I have build many small sites for myself(site to organise class
assembly which is like yearly convention..it has user administration
etc) but they all are anything else than OOP. But now, I need to help
with creating one bigger site which should be OOP. That site should
include user management(each user has it's own profile), each user can
post job and other adds in different categories. (there will be many
categories for example 'work,cars,training,apartments'.)
And users profile should show ads posted by himself.
Logic itself is simple:
1) unregistered user:
    a) I go to site, I see categories (work offers, apartment offers,
training offers, etc)
    b) I click on category I'm interested in
    c) I see ad that I'm interested in
    d) I click on it
    c) I see detailed information about it(which company posted it etc)
    d) at bottom page I see form where I can contact with ad author
2) registered user
    a) I go to site
    b) I log in, my profile page opens
    c) there I can see ads posted by me..also I can see how many times
ad is viewed etc
    d) i click on link 'Post new ad'
    e) there i choose category and probably Ajax helps to load
specific fields(for example if I choose 'Cars' as category, then
fields like      'year,transmission,color, etc' will appear.

That is short summary what that site should do. It seems quite big for
me so I'd be happy to hear any guidelines from people who have built
big sites.

Creating forms, posting data, user login etc, these things are not
problem... problem is: how to build the whole thing aimed to OOP and
use with Smarty to keep things organized.

I'm not sure but I have idea about what things I should do first:

1) think and write down any function that needs to be done(for example
different validations, functions for showing/posting form etc)
2) plan and create database?
3) create database class which handles database connection
But what next? Or am I starting all wrong?

Big thanks in advance,


Raido




--- End Message ---
--- Begin Message --- I have investigated some frameworks.. Zend and Codeiginiter but I haven't done any testing/exercises. They seem to make things much more simple/faster yes...but I'm not sure how much time it will take to get know one of them(or CakePHP). And I haven't got into reading licences...I'm sure they have got licences that restricts something(or not ?) To be honest, I kinda hate all kind of licences. There are many pages info what I can and what I can't do...but I mostly like to do what I have and want to do. Also, inventing the wheel once, might give good experience or am I going slippery way ?



Shawn McKenzie wrote:
Micah Gersten wrote:
Depending on the size of the site, you might want to consider a PHP
framework to start with.  There's usually no point in reinventing the
wheel.  Someone mentioned CakePHP which utilizes MVC.  I'm looking into
porting my stuff to the Zend Framework which makes MVC optional, but has
a lot of functionality make available.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com


I too like CakePHP. I have coded in PHP for quite a while and understand OOP and OOP in PHP, however I don't really have any experience building sites or apps from scratch using OOP/MVC.

Cake or a framework makes it much quicker and easier. For those that need total freedom to do things the way they want but need some pre-built functionality to make it quicker, Zend seems to be the choice. I consider Zend to be more of a class library like PEAR only more consistant. For me, I had no habits/best practices or preferred way when I started with OOP/MVC so Cake was great. It has a certain structure and uses certain conventions and code generation which makes it very quick and easy. The main drawback is the docs.

-Shawn



Raido wrote:
Hi,

There are many sites explaining how to build new site etc but I'd like
to hear what You suggest. (about how to plan whole thing and how to
write separate parts which can be put together later)

I have build many small sites for myself(site to organise class
assembly which is like yearly convention..it has user administration
etc) but they all are anything else than OOP. But now, I need to help
with creating one bigger site which should be OOP. That site should
include user management(each user has it's own profile), each user can
post job and other adds in different categories. (there will be many
categories for example 'work,cars,training,apartments'.)
And users profile should show ads posted by himself.
Logic itself is simple:
1) unregistered user:
    a) I go to site, I see categories (work offers, apartment offers,
training offers, etc)
    b) I click on category I'm interested in
    c) I see ad that I'm interested in
    d) I click on it
    c) I see detailed information about it(which company posted it etc)
    d) at bottom page I see form where I can contact with ad author
2) registered user
    a) I go to site
    b) I log in, my profile page opens
    c) there I can see ads posted by me..also I can see how many times
ad is viewed etc
    d) i click on link 'Post new ad'
    e) there i choose category and probably Ajax helps to load
specific fields(for example if I choose 'Cars' as category, then
fields like      'year,transmission,color, etc' will appear.

That is short summary what that site should do. It seems quite big for
me so I'd be happy to hear any guidelines from people who have built
big sites.

Creating forms, posting data, user login etc, these things are not
problem... problem is: how to build the whole thing aimed to OOP and
use with Smarty to keep things organized.

I'm not sure but I have idea about what things I should do first:

1) think and write down any function that needs to be done(for example
different validations, functions for showing/posting form etc)
2) plan and create database?
3) create database class which handles database connection
But what next? Or am I starting all wrong?

Big thanks in advance,


Raido





--- End Message ---
--- Begin Message ---
On Thu, 2008-07-31 at 09:57 +0000, Raido wrote:
> I have investigated some frameworks.. Zend and Codeiginiter but I 
> haven't done any testing/exercises. They seem to make things much more 
> simple/faster yes...but I'm not sure how much time it will take to get 
> know one of them(or CakePHP). And I haven't got into reading 
> licences...I'm sure they have got licences that restricts something(or 
> not ?) To be honest, I kinda hate all kind of licences. There are many 
> pages info what I can and what I can't do...but I mostly like to do what 
> I have and want to do. Also, inventing the wheel once, might give good 
> experience or am I going slippery way ?

I didn't find CodeIgniter difficult to learn - a few hours of reading
and a few hours of playing. I was comfortable within one evening.

The license for CodeIgniter is pretty simple. Since it's unlikely you'll
ever need to mess with the framework itself - you can override any
object - I don't see it's modification clause really coming into play.

The meat of CodeIgniter's license (from
http://codeigniter.com/user_guide/license.html):
Permitted Use
You are permitted to use, copy, modify, and distribute the Software and
its documentation, with or without modification, for any purpose,
provided that the following conditions are met:

     1. A copy of this license agreement must be included with the
        distribution.
     2. Redistributions of source code must retain the above copyright
        notice in all source code files.
     3. Redistributions in binary form must reproduce the above
        copyright notice in the documentation and/or other materials
        provided with the distribution.
     4. Any files that have been modified must carry notices stating the
        nature of the change and the names of those who changed them.
     5. Products derived from the Software must include an
        acknowledgment that they are derived from CodeIgniter in their
        documentation and/or other materials provided with the
        distribution.
     6. Products derived from the Software may not be called
        "CodeIgniter", nor may "CodeIgniter" appear in their name,
        without prior written permission from EllisLab, Inc.


--- End Message ---
--- Begin Message --- Cake is licensed under the MIT license which is about as permissible as you can get.

-Shawn

Raido wrote:
I have investigated some frameworks.. Zend and Codeiginiter but I haven't done any testing/exercises. They seem to make things much more simple/faster yes...but I'm not sure how much time it will take to get know one of them(or CakePHP). And I haven't got into reading licences...I'm sure they have got licences that restricts something(or not ?) To be honest, I kinda hate all kind of licences. There are many pages info what I can and what I can't do...but I mostly like to do what I have and want to do. Also, inventing the wheel once, might give good experience or am I going slippery way ?



Shawn McKenzie wrote:
Micah Gersten wrote:
Depending on the size of the site, you might want to consider a PHP
framework to start with.  There's usually no point in reinventing the
wheel.  Someone mentioned CakePHP which utilizes MVC.  I'm looking into
porting my stuff to the Zend Framework which makes MVC optional, but has
a lot of functionality make available.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com


I too like CakePHP. I have coded in PHP for quite a while and understand OOP and OOP in PHP, however I don't really have any experience building sites or apps from scratch using OOP/MVC.

Cake or a framework makes it much quicker and easier. For those that need total freedom to do things the way they want but need some pre-built functionality to make it quicker, Zend seems to be the choice. I consider Zend to be more of a class library like PEAR only more consistant. For me, I had no habits/best practices or preferred way when I started with OOP/MVC so Cake was great. It has a certain structure and uses certain conventions and code generation which makes it very quick and easy. The main drawback is the docs.

-Shawn



Raido wrote:
Hi,

There are many sites explaining how to build new site etc but I'd like
to hear what You suggest. (about how to plan whole thing and how to
write separate parts which can be put together later)

I have build many small sites for myself(site to organise class
assembly which is like yearly convention..it has user administration
etc) but they all are anything else than OOP. But now, I need to help
with creating one bigger site which should be OOP. That site should
include user management(each user has it's own profile), each user can
post job and other adds in different categories. (there will be many
categories for example 'work,cars,training,apartments'.)
And users profile should show ads posted by himself.
Logic itself is simple:
1) unregistered user:
    a) I go to site, I see categories (work offers, apartment offers,
training offers, etc)
    b) I click on category I'm interested in
    c) I see ad that I'm interested in
    d) I click on it
c) I see detailed information about it(which company posted it etc)
    d) at bottom page I see form where I can contact with ad author
2) registered user
    a) I go to site
    b) I log in, my profile page opens
    c) there I can see ads posted by me..also I can see how many times
ad is viewed etc
    d) i click on link 'Post new ad'
    e) there i choose category and probably Ajax helps to load
specific fields(for example if I choose 'Cars' as category, then
fields like      'year,transmission,color, etc' will appear.

That is short summary what that site should do. It seems quite big for
me so I'd be happy to hear any guidelines from people who have built
big sites.

Creating forms, posting data, user login etc, these things are not
problem... problem is: how to build the whole thing aimed to OOP and
use with Smarty to keep things organized.

I'm not sure but I have idea about what things I should do first:

1) think and write down any function that needs to be done(for example
different validations, functions for showing/posting form etc)
2) plan and create database?
3) create database class which handles database connection
But what next? Or am I starting all wrong?

Big thanks in advance,


Raido





--- End Message ---
--- Begin Message ---
> Cake is licensed under the MIT license  which is about as permissible as you
> can get.

Any Open Source code is permissable as long you don't tell anyone... :-)

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
Konrad Priemer wrote:
Moin,

kann mir mal wer auf die Sprünge helfen, ich bekomme es gerade nicht
geregelt ein Image "on-the-fly" von einem Remote-Host per fsockopen auf
meinen Server zu ziehen.

Irgendwo hab ich da voll die Blockade ;)

Mein "nichtfunktionierender" Versuch:

...

Gutentag,

Enschuldigung fur meine Deutsche schreibe. Aber Ich habe jetzt menige Jahren kein Deutsch geschrieben.
...

$out = "GET ".<URL_REMOTE_IMAGE>." HTTP/1.0\r\nHost:
".$this->host."\r\nUser-Agent: GetWiki for WordPress\r\n\r\n";

$fp = fsockopen($this->host, $this->port, $errno, $errstr, 30);

$File = fopen(<PFAD_ZUM_ASPEICHERN>,"wb");
fwrite( $File, $out );

Was Sie hier macht is nicht richtig. Sie schreiben $out nach $File, weil $out mußt zum $fp geschrieben werden.

$fp Ist die Remote Host, und $out ist die Request. Die ervolg ist das $fp gibt Sie ein Response, und konnen mit fgets() oder fread() ausgelesen worden.

Wieso, $tmp = fgets($fp); Und weiter Sie konnen $tmp ins $File schreiben.
fclose($File);

fclose($fp);
Vielleicht ist es nicht gar richtig, aber Sie konnen das doch testen.

Viel Spaß mit coding.

Grüße

Aschwin Wesselius

--- End Message ---
--- Begin Message ---
> Gutentag,

I'm staring at the screen thinking "Huh...?".

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
Gutentag,

I'm staring at the screen thinking "Huh...?".


He didn't even apologize for his English!

-Shawn

--- End Message ---
--- Begin Message ---
Daniel Brown wrote:
On Wed, Jul 30, 2008 at 9:50 PM, Konrad Priemer <[EMAIL PROTECTED]> wrote:
kann mir mal wer auf die Sprünge helfen, ich bekomme es gerade nicht
geregelt ein Image "on-the-fly" von einem Remote-Host per fsockopen auf
meinen Server zu ziehen.

Irgendwo hab ich da voll die Blockade ;)


    Die copy() Funktion kann mit URL arbeiten.

        http://php.net/copy


No,

http://us2.php.net/manual/de/function.copy.php

-Shawn

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

Can someone tell me what the address is to change my @php.net redirect? Thanks.

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
Thanks for the nice explanation, Dan!

On 7/30/08, Daniel Brown <[EMAIL PROTECTED]> wrote:
>
> On Wed, Jul 30, 2008 at 6:51 PM, Stephen <[EMAIL PROTECTED]> wrote:
> > I have traditionally used double quotes going back to my PASCAL days.
> >
> > I see many PHP examples using single quotes, and I began to adopt that
> > convention.
> >
> > Even updating existing code.
> >
> > And I broke some stuff that was doing variable expansion. So I am back to
> > using double quotes.
> >
> > But I wonder, is there any reason to use single quotes?
>
>    Single quotes means literal, whereas double quotes means translated.
>
>    For example:
>
> <?php
>
> // This returns exactly the same data:
> $foo_a = "bar";
> $foo_b = 'bar';
>
> echo $foo_a; // bar
> echo $foo_b; // bar
>
>
> // This returns different data:
> $foo = "bar"; // Single quotes can be used here just the same.
>
> echo "The answer is $foo"; // The answer is bar
> echo 'The answer is $foo'; // The answer is $foo
>
>
> /* And if you want to use special
>    characters like newlines, you
>    MUST use double quotes. */
>
> echo "This echoes a newline.\n"; // This echoes a newline. [newline]
> echo 'This echoes a literal \n'; // This echoes a literal \n
>
> ?>
>
>    Basically, double quotes evaluate certain things and return the
> evaluation, while single quotes return EXACTLY what's typed between
> them.
>
> --
> </Daniel P. Brown>
> Better prices on dedicated servers:
> Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
> Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
> Dedicated servers, VPS, and hosting from $2.50/mo.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Single quotes do still recognise \' and \\ though, for getting a
single quote and backslash. IIRC (which isn't likely) they're the only
two.

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
On Wed, Jul 30, 2008 at 6:51 PM, Stephen <[EMAIL PROTECTED]> wrote:
> I have traditionally used double quotes going back to my PASCAL days.
>
> I see many PHP examples using single quotes, and I began to adopt that
> convention.
>
> Even updating existing code.
>
> And I broke some stuff that was doing variable expansion. So I am back to
> using double quotes.
>
> But I wonder, is there any reason to use single quotes?
>
> Stephen

Because sometimes it is nice to do this:

$onclick = ' onclick="..."'

Not having to escape my single tick makes it more readable.

--- End Message ---
--- Begin Message ---
On Wed, Jul 30, 2008 at 7:03 PM, mike <[EMAIL PROTECTED]> wrote:
> On 7/30/08, Stephen <[EMAIL PROTECTED]> wrote:
>
>> But I wonder, is there any reason to use single quotes?
>
> extremely minor performance gains, afaik.
>
> probably moreso when doing $foo["bar"] and $foo['bar']
>
> but i believe it's negligible $foo = 'bar' and $foo = "bar"
>
> sara golemon did some performance tests with actual opcode results here:
> http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I read one of Ilia's presentation slides saying this was a myth.
Strings probably aren't the bottleneck.

--- End Message ---
--- Begin Message ---
I'm trying to upload the file. It's showing me successfully uploaded.
But it's not able to move from temp directory to my defined directory

my code:

if (is_uploaded_file($_FILES['myfile']['tmp_name'])) {
   move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename);
   echo "File ". $_FILES['myfile']['name'] ." uploaded successfully.\n";
} else {
 echo "File uploading error";
}

Thanks in advance.

-Jignesh

--- End Message ---
--- Begin Message ---
On Thu, Jul 31, 2008 at 10:18 AM, Jignesh Thummar
<[EMAIL PROTECTED]> wrote:
> I'm trying to upload the file. It's showing me successfully uploaded.
> But it's not able to move from temp directory to my defined directory
>
> my code:
>
> if (is_uploaded_file($_FILES['myfile']['tmp_name'])) {
>   move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename);
>   echo "File ". $_FILES['myfile']['name'] ." uploaded successfully.\n";
> } else {
>  echo "File uploading error";
> }
>
> Thanks in advance.
>
> -Jignesh

Is the directory you're moving to writable by your web server?  If you
don't know, try making a separate script that tries
var_dump(is_writable('/path/to/uploads'));

--- End Message ---
--- Begin Message ---
it's writable.

On Thu, Jul 31, 2008 at 3:37 PM, Eric Butera <[EMAIL PROTECTED]> wrote:
> On Thu, Jul 31, 2008 at 10:18 AM, Jignesh Thummar
> <[EMAIL PROTECTED]> wrote:
>> I'm trying to upload the file. It's showing me successfully uploaded.
>> But it's not able to move from temp directory to my defined directory
>>
>> my code:
>>
>> if (is_uploaded_file($_FILES['myfile']['tmp_name'])) {
>>   move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename);
>>   echo "File ". $_FILES['myfile']['name'] ." uploaded successfully.\n";
>> } else {
>>  echo "File uploading error";
>> }
>>
>> Thanks in advance.
>>
>> -Jignesh
>
> Is the directory you're moving to writable by your web server?  If you
> don't know, try making a separate script that tries
> var_dump(is_writable('/path/to/uploads'));
>

--- End Message ---
--- Begin Message ---
On Jul 30, 2008, at 1:29 PM, Jim Lucas wrote:

Marten Lehmann wrote:
Hello,
I'm using some php-classes which worked fine with php-5.0.4. Now I tried to upgrade to php-5.2.6, but the classes give a lot of errors. If I set
error_reporting(E_ALL);
I see messages like
Notice: Undefined property: FastTemplate::$main in /whereever/ inc.template.php on line 293 Notice: Undefined property: current_session::$cust_id in /whereever/ inc.init.php on line 117 In inc.template.php there are a lot of calls like $this->$key. In inc.init.php there are calls like $session->cust_id.

to fix these errors, you would need to modify the code so it does something like this.

where it calls $this->$key you need to check and make sure that $key exists before you trying call for it.

So something like this would work.

if ( isset( $this->$key ) ) {
        $this->$key;
} else {
        $this->$key = null;
}

You didn't show any context in which you are using the above code. So I don't know what will actually work in your situation. Show a little more code that includes the method in which $this->$key is called.

You will want to look at using the Overloading feature of PHP5. Check out this page for overloading examples

http://us2.php.net/manual/en/language.oop5.overloading.php

Take note of the __get() and __set() methods. The __get method checks to see if the key exists before it tries working with it.

Ok, I'm trying to understand the point to using these overloading methods.

<?php
$obj = new ClassThatUsesOverloading ();
$obj->hi = 'Hi';
$obj->bye = 'Bye';

echo $obj->hi, ' ', $obj->bye;
// Output: Hi Bye
?>

You could have done that or you could do the following.....

<?php
$obj = new ClassThatDoesntUseOverloading ();
$obj->setHi('Hello');
$obj->setBye('Bye Bye!');

echo $obj->hi(), ' ', $obj->bye();
// Output: Hello Bye Bye!
?>

The 2nd way seems more *OOP* than the first - weird to explain. I guess what I'm wanting to know is.... why would you use overloading (in PHP)? The only reason I can think of is to avoid having to create/ use accessors. Please help me understand! But please be nice! =D

Thanks,
~Philip


What has changed in php-5.2.x so that these calls don't work any more? What is the new, required form to use objects in a similar manner (unfortunately I have no ressources to code these classes from scratch)? Thanks.
Kind regards
Marten

--- End Message ---
--- Begin Message ---
Hello,

with PHP 5.0.x this two lines of code returned "{TEST}":

$var = "TEST";
print "\{$var}";

But with PHP 5.2.x, the same code returns "\{TEST}"

If I remove the backslash:

$var = "TEST";
print "{$var}";

then just "TEST" is return (without any brackets).

What is the recommended way for PHP 5.2.x to work with that? It looks a bid odd if I have to write

print "{". $var. "}";

instead.


Regards
Marten

--- End Message ---
--- Begin Message ---
On Thu, 2008-07-31 at 17:54 +0200, Marten Lehmann wrote:
> Hello,
> 
> with PHP 5.0.x this two lines of code returned "{TEST}":
> 
> $var = "TEST";
> print "\{$var}";
> 
> But with PHP 5.2.x, the same code returns "\{TEST}"
> 
> If I remove the backslash:
> 
> $var = "TEST";
> print "{$var}";
> 
> then just "TEST" is return (without any brackets).
> 
> What is the recommended way for PHP 5.2.x to work with that? It looks a 
> bid odd if I have to write
> 
> print "{". $var. "}";

Yeah, that is weird. I'd write:

    echo '{'.$var.'}';

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---

Reply via email to