Ahmad Farid
Ahmad Farid

Reputation: 14774

How to receive data of an HTTPS website in a string PHP?

Is there a function to which you give the URL of a website and it returns back the source in a string?

Upvotes: 3

Views: 122

Answers (1)

Gordon
Gordon

Reputation: 316979

Yes,

  • file_get_contents — Reads entire file into a string. A URL can be used as a filename with this function if the fopen wrappers have been enabled.

Example:

file_get_contents('https://www.example.com');

Otherwise cURL and HTTP will do.

If you want to parse the contents on the page, you will likely want use a DOM Parser instead.

Upvotes: 2

Related Questions