Get the full URL in PHP

Have a look at $_SERVER[‘REQUEST_URI’], i.e. (Note that the double quoted string syntax is perfectly correct) If you want to support both HTTP and HTTPS, you can use Editor’s note: using this code has security implications. The client can set HTTP_HOST and REQUEST_URI to any arbitrary value it wants.

What are namespaces?

Namespacing does for functions and classes what scope does for variables. It allows you to use the same function or class name in different parts of the same program without causing a name collision. In simple terms, think of a namespace as a person’s surname. If there are two people named “John” you can use their … Read more

“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP

Notice: Undefined variable From the vast wisdom of the PHP Manual: Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register_globals turned on. E_NOTICE level error is issued in case of working with uninitialized variables, however not … Read more

How to fix “Headers already sent” error in PHP

No output before sending headers! Functions that send/modify HTTP headers must be invoked before any output is made. summary ⇊ Otherwise the call fails: Warning: Cannot modify header information – headers already sent (output started at script:line) Some functions modifying the HTTP header are: header / header_remove session_start / session_regenerate_id setcookie / setrawcookie Output can be: Unintentional: Whitespace before <?php or after ?> The UTF-8 Byte Order Mark specifically Previous … Read more

Whoops, looks like something went wrong. Laravel 5.0

The logs are located in storage directory. If you want laravel to display the error for you rather than the cryptic ‘Whoops’ message, copy the .env.example to .env and make sure APP_ENV=local is in there. It should then show you the detailed error messaging.

PHP page redirect

Yes, you would use the header function. It is a good practice to call exit() right after it so that code below it does not get executed. Also, from the documentation: Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a … Read more

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