{"id":8405,"date":"2021-11-11T22:10:00","date_gmt":"2021-11-12T03:10:00","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=8405"},"modified":"2021-11-15T14:15:38","modified_gmt":"2021-11-15T19:15:38","slug":"where-did-that-come-from-php-class","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=8405","title":{"rendered":"Where did THAT come from? (PHP class)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I&#8217;ve got some code that is cobbled together from a couple of different places &amp; it&#8217;s got namespace collisions that wouldn&#8217;t exist if I&#8217;d been starting from scratch. But I&#8217;ve got what I&#8217;ve got &#8230; and, occasionally, new code falls over because a class has already been declared. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Luckily, there&#8217;s a way to find out from where a class was loaded:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n\t\t\t$strClassName = &quot;Oracle_Cred&quot;;\n\t\t\tif( class_exists($strClassName) ){\n\t\t\t\t$reflector = new \\ReflectionClass($strClassName);\n\t\t\t\techo &quot;Class $strClassName was loaded from &quot; . $reflector-&gt;getFileName();\n\t\t\t}\n\t\t\telse{\n\t\t\t\techo &quot;Class $strClassName does not exist yet&quot;;\n\t\t\t}\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve got some code that is cobbled together from a couple of different places &amp; it&#8217;s got namespace collisions that wouldn&#8217;t exist if I&#8217;d been starting from scratch. But I&#8217;ve got what I&#8217;ve got &#8230; and, occasionally, new code falls over because a class has already been declared. Luckily, there&#8217;s a way to find out &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[45,777,35],"class_list":["post-8405","post","type-post","status-publish","format-standard","hentry","category-coding","tag-coding","tag-development","tag-php"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/8405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8405"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/8405\/revisions"}],"predecessor-version":[{"id":8406,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/8405\/revisions\/8406"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}