The first argument is the pattern to search, the slashes are delimiters; the second argument is the subject to search, your string; the third argument is the array that will hold the results; the last argument is a constant to show the position of each match in the researched subject.
About the docs: at the end of each function page, there is a list of other functions to consider as alternative. If you open php.net/strpos you get preg_match, which would return only $matches, from there you can reach preg_match_all. Once you get used, you just have to explore and test.
Curious to see what the code would look like and php is capable of doing it in how many lines of code.
Hehe, I think you can try to extract the tweet through a DOM library (DOM Crawler should be easy to use), check the HTML source of the link you provided, load the page and see what you can get from there.
It, probably, happens because you are calling the session inside application/core/MY_Loader.php but you are loading it from the controller, which is executed after the MY_Loader. Have you tried to autoload the session?
from the screenshot is seems you are trying to load CI resources from outside the application folder. Is Contact.php a CI controller? Can you share it? Remember to remove address and password as the post is public.
In addition to previous suggestion: if the path is wrong or does not have write permissions Python would return:
sqlite3.OperationalError: unable to open database file
Instead you get:
sqlite3.OperationalError: no such table: Airports
Which can be generated if:
the database file name is wrong due, for example, to the case: linux is case sensitive, Mac OS no (at least not by default)
the database file or the parent directory is read-only, so you have to change the permissions
the table does not exists
In the first case connect() will create the database file, but this obviously won't have the Airports table.
In the first case this:
for row in cur.execute('''SELECT "Hello"'''):
will run successfully, it will run successfully also if the file is read-only, but it will fail if there are permission issues with the parent directory. The error, however, will be related to the database file, not to the table.
To be honest, a part personal code, I have used PHP 7 only for one client's project because it was starting with that version, in that case I used strict type declarations, CSPRNG functions and Throwable to catch common errors.
For me the former and the latter were missing bits in PHP. I'm happy these were introduced. I would like to see Throwable also for warnings and notices rather than setting an error handler.
Are they massive time savers (coding-wise or run-wise)?
At the moment no, not for me.
Something I would like to see is overloading, what is currently used in PHP smells more like overriding and I find it chaotic.
BUT right now the img() function can, potentially, allow the access to the contents of any directory on the server, by adding ../ to the variable, as example you can write the following and access /etc/:
It depends on the position of the document root in the file system. You could use an integer and make sure it's valid, for example:
$imageID = filter_input(INPUT_GET, 'imageID', FILTER_VALIDATE_INT, ['options' => ['default' => NULL]]);
if(TRUE === is_null($imageID))
# redirect or show 404
# continue if $imageID is valid
in addition to previous comments, if you are learning PHP for work, sooner or later you will handle legacy code, you will be asked to add functionalities, not always to port it. You cannot always choose the version to work with. For example, something simple like:
$i = 1024**2*10;
returns a syntax error if you use PHP <= 5.5 and works fine when using the latest versions. To avoid issues in such case, you would write:
$i = 1024*1024*10;
Or see how list() changed the behaviour between PHP 5 and 7 when using array indices, that's just insane (it was from the beginning). IMHO, you need to know these things too, to become more efficient.