What does __FILE__ mean?

The realpath() function gives you the file-system path, with any symbolic links and directory traversing (e.g. ../../) resolved. The dirname() function gives you just the directory, not the file within it. __FILE__ is a magic constant that gives you the filesystem path to the current .php file (the one that __FILE__ is in, not the one it’s included by if it’s an … Read more

How to call a JavaScript function from PHP?

As far as PHP is concerned (or really, a web server in general), an HTML page is nothing more complicated than a big string. All the fancy work you can do with language like PHP – reading from databases and web services and all that – the ultimate end goal is the exact same basic … Read more

How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?

Difference between == and === The difference between the loosely == equal operator and the strict === identical operator is exactly explained in the manual: Comparison Operators ┌──────────┬───────────┬───────────────────────────────────────────────────────────┐ │ Example │ Name │ Result │ ├──────────┼───────────┼───────────────────────────────────────────────────────────┤ │$a == $b │ Equal │ TRUE if $a is equal to $b after type juggling. │ │$a === $b │ Identical │ TRUE if $a is … Read more

How do I run a file on localhost?

Ok, thanks for the more specific info, ppl may remove their downvotes now… What you are proposing is a very common thing to do! You want to run your web application locally without uploading it to your host yet. That’s totally fine and that’s what your Apache is there for. Your Apache is a web … Read more

Could not open input file: artisan

When trying to create a new laravel project, The following error appears on the CLI: Could not open input file: artisan Script php artisan clear-compiled handling the post-install-cmd event returned with an error I am using the latest version of XAMPP v3.2.1 with PHP 5.5.15 and with mcrypt enabled (made sure of that by issuing … Read more

Converting string to Date and DateTime

Use strtotime() on your first date then date(‘Y-m-d’) to convert it back: Make note that there is a difference between using forward slash / and hyphen – in the strtotime() function. To quote from php.net: Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)