Included class inside another class is not declared PHP -


मैं एक selfmade वर्ग के निम्नलिखित __construct;

  सार्वजनिक समारोह __construct ($ आईपी , $ उपयोगकर्ता, $ पास, $ उत्पाद) {$ this- & gt; _ip = $ ip; $ This- & gt; _user = $ उपयोगकर्ता; $ This- & gt; _pass = $ pass; $ This- & gt; _product = $ उत्पाद; $ This- & gt; ssh = नया Net_SSH2 ($ this- & gt; _ip); अगर (! $ this- & gt; ssh- & gt; लॉगिन ($ this- & gt; _user, $ this- & gt; _pass)) {लौटें 'लॉग इन असफल'; } $ this- & gt; sftp = नया Net_SFTP ($ this- & gt; _ip); अगर ($ इस- & gt;! sftp- & gt; लॉगिन ($ इस- & gt; _user, $ इस- & gt; _pass)) {वापसी 'प्रवेश विफल'; }}   

अब समस्या यह है कि यह कहता है Net_SSH2 और Net_SFTP घोषित नहीं किया है, लेकिन मैं, im यकीन नहीं पेज में उन वर्गों को शामिल किया है, लेकिन यह हो सकता है मैं पारित करने के लिए है कि है उन कक्षाओं में उन वर्गों को बस फोन करने के बजाय? यदि हां, तो कैसे मैं ऐसा कर सकता हूँ?

एक बेहतर समाधान autoload उपयोग करने के लिए है। <पूर्व> फ़ंक्शन __autoload ($ class_name) {require_once $ class_name} '.php'; }

अब, जब आप एक नया वर्ग के लिए पूछना है, यह स्वत: लोड किया जाएगा।

इस प्रयास करें।

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -