Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-29-2005, 09:06 AM
WebProWorld Member
 

Join Date: Mar 2005
Posts: 29
abalfazl RepRank 0
Default instantiate an object dynamically

Hello firends

How to instantiate an object dynamically?(When we dont know name of class until our code is executed)

Please give me an example.
Reply With Quote
  #2 (permalink)  
Old 03-29-2005, 09:22 AM
paulhiles's Avatar
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: UK
Posts: 2,803
paulhiles RepRank 0
Default So many questions

Can't answer your question, but I don't really see any relevance to Web Programming either. What exactly are you trying to do here? I have a suspicion these are questions being asked as part of a programming course.

Maybe we need to introduce a separate forum purely for all of these "hard-core" PHP questions!
Reply With Quote
  #3 (permalink)  
Old 03-29-2005, 09:32 AM
WebProWorld Member
 

Join Date: Mar 2005
Posts: 29
abalfazl RepRank 0
Default Please guide,Thanks

Dear sir

See,Honestly,I'm learning PHP by these:

PHP 5 my sql bible

PHP 5 for dummies

I laso read Php manually form php.net

I wanna learn object oriented chapters.But I can't

Then Please guide me about these,

Thank you very much indeed
Reply With Quote
  #4 (permalink)  
Old 03-29-2005, 08:01 PM
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Cornwall, UK
Posts: 862
speed RepRank 1
Default

Code:
<?php
class test {
  function a() {
    echo "Hello World\n";
  }
}

$clsName = 'test';

$obj = new $clsName();
$obj->a();
?>
That works in PHP4, I haven't tried it in PHP5 but it will probably work.

Personally I quite like the books "PHP Cookbook" and "Programming PHP" from O'Reilly.

Quote:
Can't answer your question, but I don't really see any relevance to Web Programming either.
Paul, I can think of a few uses for this on large complex web projects.
__________________
US & UK Web Hosting with hourly backups | Hosting Affiliate Scheme | Web Directory 2 for 1 Offer
Reply With Quote
  #5 (permalink)  
Old 03-29-2005, 09:47 PM
ADAM Web Design's Avatar
WebProWorld 1,000+ Club
 

Join Date: Dec 2003
Location: Toronto, Ontario, Canada
Posts: 2,217
ADAM Web Design RepRank 0
Default

I'm with Paul. Something doesn't seem right with these questions. They're both too generic and too theoretical to apply to specific instances.

abalfazi: I'm guessing that the questions that you have may be symptoms of a deeper problem. Forgive me for saying this, but it is fairly obvious that English isn't your mother tongue. My suggestion, if you wish to learn these languages from textbooks, is to do one of two things:

1) Purchase textbooks in your native language.

2) Acquire a better grasp of the English language.

Again, this is intended as a constructive criticism, not a derogatory one, and I ask that you interpret it as such.
Reply With Quote
  #6 (permalink)  
Old 03-30-2005, 06:24 AM
paulhiles's Avatar
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: UK
Posts: 2,803
paulhiles RepRank 0
Default

Quote:
Originally Posted by speed
Paul, I can think of a few uses for this on large complex web projects.
I'm sure on some level this question may well have a relevance.

My point is more of a general one, aimed at the growing list of unanswered questions.
If you look at the context in which abalfazl's questions are asked. There's no background information supplied, they do not directly relate to any specific problem. They look like academic questions you might find at the end of a chapter in a textbook or in a college worksheet.

Paul
Reply With Quote
  #7 (permalink)  
Old 03-31-2005, 12:30 AM
WebProWorld Member
 

Join Date: Mar 2005
Posts: 29
abalfazl RepRank 0
Default Sorry

First of all, thanks for your answer dear Speed. I

agree with you that "PHP CookBook" is an interesting

book, especially chapter 7 .


And others, instead of praising each other, you

better go and take a look at the chapter!

I'm sorry that am registered in a forum of this kind

with such suggestions and knowledge of this level.


Thanks for reading.


Bye.
Reply With Quote
  #8 (permalink)  
Old 03-31-2005, 06:19 AM
paulhiles's Avatar
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: UK
Posts: 2,803
paulhiles RepRank 0
Default Sorry to see you go

Sorry to see you go abalfazl.
I think a technical forum with a dedicated PHP section is probably more suited to your needs.

I see you've tried several other forums with very similar questions.
http://www.phpaddict.com/view_user.php?id=1123&posts=1
http://www.php-forum.com/p/search.ph...uthor=Abalfazl
http://www.sitepoint.com/forums/showthread.php?t=243545
http://webdeveloper.internet.com/for...ad.php?t=60667
http://www.weberforums.com/search.ph...uthor=abalfazl

Sitepoint seems to have provided you with the most comprehensive replies - maybe you should focus on them?

Good luck!

Paul
Reply With Quote
  #9 (permalink)  
Old 04-04-2005, 05:24 PM
WebProWorld Pro
 

Join Date: Feb 2004
Location: England Baby!
Posts: 222
icb01co2 RepRank 0
Default

Quote:
Can't answer your question, but I don't really see any relevance to Web Programming either.
Are you suggesting that there's no need for object orientated programming for the web? These questions didnt seem like coursework to me. Just a case of someone who wants to learn something new.
Reply With Quote
  #10 (permalink)  
Old 04-04-2005, 05:41 PM
WebProWorld Pro
 

Join Date: Feb 2004
Location: England Baby!
Posts: 222
icb01co2 RepRank 0
Default

Sorry paulhiles,

I didnt notice the other 10 or so posts abalfazl had added. Yup, it definately looks like last minute revision in a topic he obviously has very little knowladge about. All the questions are very abstract to say the least.
Reply With Quote
  #11 (permalink)  
Old 04-04-2005, 05:58 PM
paulhiles's Avatar
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: UK
Posts: 2,803
paulhiles RepRank 0
Default

No problem Chris!

For what it's worth, I'm all in favour of object oriented programming for web applications! ;o)

Paul
Reply With Quote
  #12 (permalink)  
Old 04-04-2005, 08:31 PM
ADAM Web Design's Avatar
WebProWorld 1,000+ Club
 

Join Date: Dec 2003
Location: Toronto, Ontario, Canada
Posts: 2,217
ADAM Web Design RepRank 0
Default

Thou shalt not question thy programming Mod-God. Paul is wise in the ways of those who wish to gain knowledge for the purposes of completing a conceptual obligation.

Be thee well and truly warned, my people. If thou art guilty of the sin of gaining knowledge from WPW for the purposes of completing thy educational assignments, Paul will smiteth down upon thine ass with British dry wit used to mask annoyance.

(Okay, that's as British as I get.)
Reply With Quote
  #13 (permalink)  
Old 04-05-2005, 05:36 AM
paulhiles's Avatar
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: UK
Posts: 2,803
paulhiles RepRank 0
Default

LOL!! Spoken like a native!
ADAMWebDesign, You've been watching way too much Monty Python but point taken! :o)

Paul
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0