473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

smth like Class.forName() in PHP?

Is there a way to create an instance of a class SomeClass in PHP having
a string "SomeClass"? The idea is to create instances on classes based
on dynamic information obtained from $_POST. Like

Java has a useful construct for that - Class.forName(). Is it possible
to do same in PHP? Like:

$obj = createClass($_POST['className'])

or smth?
Jun 2 '08 #1
1 3082
Sergei Riaguzov wrote:
Is there a way to create an instance of a class SomeClass in PHP having
a string "SomeClass"?
$className='SomeClass';

$var=new $className();
Jun 2 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Fu Bo Xia | last post by:
the java.lang.Object.forName method takes a java class name and returns a Class object associated with that class. eg. Class myClass = Object.forName("java.lang.String"); by if i only know the...
2
by: Vijay Singh | last post by:
How do you instantiat a class with a Class.forName( ) method, if the class's default constructor requires a parameter?
4
by: Gavin Andrews | last post by:
I use log4j for logging and tend to include the following snipet in all my classes... public class MyClass { // Logging Declarations private static String _className; private static Category...
0
by: Phoneix | last post by:
Hello , I have a necessity to delete a jar file which is in the CLASSPATH. But JVM locks it after a class.forName() call, even though the class loaded is NOT in the JAR file I want to delete. ( I...
14
by: Alex Hunsley | last post by:
Does python provide a way to dynamically use modules and/or classes? I'm thinking in the vein of Java's Class.forName. As a pseudocode example, I'm looking for the following ability: ...
1
by: Mandar | last post by:
How do i instantiate a class if I get the name of the class at runtime ? I am looking for something like class.forname("classABC") in Java . TIA Mandar
16
by: Manuel | last post by:
hi, In the past I made the question "how to implement a simple class forname". I made this finally and it compiled well. but now when i execute the program, it crash with a sigsegv. The code...
2
by: jean-francois | last post by:
In java you can do it with Class.forName("myClass").newInstance(); this will return you a new instance of the class myClass, provided that you defined it elsewhere. How can I get this in c++...
4
by: vasavimaruthi | last post by:
hi, i got class not found exception of a small jdbc program in windows. the program is like this import java.sql.*; public class Db1 { public static void main(String a)...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.