Is there a simple way to get the class name without the namespace without using Reflection? This is my class and when I call get_class() I get CRMPiccoBundleServicesRFCWebhookSiteCancelled Answer Or simply exploding the return from class_name and getting the last element: Or simply removing the namespace from the output of get_class: Either works with or without namespace. And so on.
Tag: class
Variable variables in classes using PHP 7
Actually I’m migrating a bigger project from PHP 5.3.3 to PHP 7.1.13. In older versions of PHP it was possible to code following access to variable variables: This shows: Using the same code in PHP 7 it shows: In PHP 7 I figured out, that I have to use this way to get the same result: I found in the
What am I doing wrong with my optional PHP arguments?
I have a the following class: So from my interpretation I should be able to pass either $id or $humanIdentifier to that constructor, neither or both if I wanted. However, when I call the code below I am finding that its the $id in the constructor args being set to hello world and not the $humanIdentifier, despite me specifying the
Declare an object in PHP using constant to hold class name (like you can do with variables)?
This question about syntax/syntax capabilities in PHP. Take for example, using variables to store class names when declaring objects: $className= ‘myClass’; $obj = new $className; I was wondering …
Mysqli class not found. Using percona, php5-fpm, nginx, phalcon
Fatal error: Class ‘TKStdlibmysqli’ not found in /var/www/tk-browser-app/application/library/tk-stdlib/DbAbstract.php on line 28 It sounds like I need mysqli installed. Yea I know, but it says it’s …
Create instances of all classes in a directory with PHP
I have a directory with several PHP files consisting of classes with the same names as the files. (Sample.php’s class will be called Sample.) Each of these classes have a function called OnCall(). How can I create an instance of every class in my directory and execute all of their OnCall()s? I cannot do it manually ($sample = new Sample();
PHP Classes: Should I use 2 classes or 1?
I am currently trying to make a class that deals with a survey in PHP (Drupal). So far I have this: This is great, I can create a new instance of Survey, set the properties, and call save on it. However, I also want to be able to have methods that retrieve the results of these surveys from the DB
Custom mysqli prepare function
I’m doing my first own database class at the moment and currently I’m doing the prepare function. What this function does is to take in an SQL-query and then an array containing the variables for the …
understanding why echo doesnt work within a php class function
I’m trying to debug a class and using print_r and echo to view the variables as the script progresses. However for some reason I can’t seem to get any output from within the function, i’ve declared the function public but can’t get any output using print, echo or print_r. I’m misunderstanding something fundamental here – can anyone help please. here’s
XXX is not a valid entity or mapped super class // and config options
I just started to use Doctrine2 and I have an error when I want to persist an entity. Here is my error: ‘Class “Myappappentityuser” is not a valid entity or mapped super class.’ eAccelerator is not installed on my computer. My app (I don’t use Symfony) structure is like that: MyApp app entity core external Doctrine And I initialize Doctrine