Skip to content

Tag: php

In PHP, what does “<<<" represent?

For example: Answer That’s heredoc syntax. You start a heredoc string by putting <<< plus a token of your choice, and terminate it by putting only the token (and nothing else!) on a new line. As a convenience, there is one exception: you are allowed to add a single semicolon after the end delim…

Scraping a messy html website with PHP

I am in the following situation. I am trying to convert a messy scraped html code to a nice and neat xml structure. A partial HTML code of the scraped website: Now I want to create the following xml structure with php: Have been trying the simple html dom method, but have no idea how to get the next sibling

Fastest Way to Serve a File Using PHP

I’m trying to put together a function that receives a file path, identifies what it is, sets the appropriate headers, and serves it just like Apache would. The reason I am doing this is because I need to use PHP to process some information about the request before serving the file. Speed is critical vir…

Testing php / mysqli connection

I am looking for a way to test just the connection portion of a php / mysqli connection. I am migrating from a LAMP server build on Vista to the same on Ubuntu and am having fits getting mysqli to work. I know that all of the proper modules are installed, and PhpMyAdmin works flawlessly. I have migrated a sit…

How to iterate UTF-8 string in PHP?

How to iterate a UTF-8 string character by character using indexing? When you access a UTF-8 string with the bracket operator $str[0] the utf-encoded character consists of 2 or more elements. For example: but I would like to have: It is possible with mb_substr but this is extremely slow, ie. Is there another …

Difference between “include” and “require” in php

Is there any difference between them? Is using them a matter of preference? Does using one over the other produce any advantages? Which is better for security? Answer You find the differences explained in the detailed PHP manual on the page of require: require is identical to include except upon failure it wi…