eatc7402 Posted April 1, 2011 Share Posted April 1, 2011 I am a new simplehtmldom user. It is working and the php api loads, and I can parse when I lod data from a string. But if I attemp yo load data from a file like this... $html->file_get_html("C:\eaahmpg\eatc7402\www\stations\Sydney\code\table_data.txt"); I receive the following error. Fatal error: Call to undefined method simple_html_dom::file_get_html() in... Hmmm. The function IS defined in the api. I'm not sure where I'M going wrong here. eac7402 Link to comment https://forums.phpfreaks.com/topic/232383-problem-loading-a-file-into-simplehtmldom/ Share on other sites More sharing options...
Adam Posted April 1, 2011 Share Posted April 1, 2011 I've never used it before, but from what I found on Google it looks like file_get_html() is just a standalone function that returns the object. I.e. you call it like: $html = file_get_html("C:\eaahmpg\eatc7402\www\stations\Sydney\code\table_data.txt"); Link to comment https://forums.phpfreaks.com/topic/232383-problem-loading-a-file-into-simplehtmldom/#findComment-1195418 Share on other sites More sharing options...
eatc7402 Posted April 1, 2011 Author Share Posted April 1, 2011 Ahhh yes.. an EQUAL sign... that fixed that error.. but NOW I get this... Warning: file_get_contents(C:\eaahmpg\eatc7402\www\stations\Sydney\code able_data.txt) [function.file-get-contents]: failed to open stream: Invalid argument in C:\eaahmpg\eatc7402\www\php\simplehtmldom\simple_html_dom.php on line 39 An argument? What does it need here.. if I give it an empty argument is complains also. $html = file_get_html("C:\eaahmpg\eatc7402\www\stations\Sydney\code\table_data.txt", ""); eatc7402 Link to comment https://forums.phpfreaks.com/topic/232383-problem-loading-a-file-into-simplehtmldom/#findComment-1195449 Share on other sites More sharing options...
eatc7402 Posted April 1, 2011 Author Share Posted April 1, 2011 I altered my code and when I called the function WITHOUT a file path like this... $html = file_get_html("table_data.txt"); it no longer complains about any missing arg. So... what is the required arg if I want to fully specify the path to the file?? eatc7402 Link to comment https://forums.phpfreaks.com/topic/232383-problem-loading-a-file-into-simplehtmldom/#findComment-1195454 Share on other sites More sharing options...
Adam Posted April 1, 2011 Share Posted April 1, 2011 "\t" in PHP is the special tab-character. As your path is in double quotes this special meaning is preserved, which is noticable if you look at the file path shown within the error: Warning: file_get_contents(C:\eaahmpg\eatc7402\www\stations\Sydney\code able_data.txt) [function.file-get-contents]: failed to open stream: Invalid argument in C:\eaahmpg\eatc7402\www\php\simplehtmldom\simple_html_dom.php on line 39 You can either use single quotes, in which "\t" will not be converted to a tab-character, or escape it with a second backslash. Link to comment https://forums.phpfreaks.com/topic/232383-problem-loading-a-file-into-simplehtmldom/#findComment-1195470 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.