Tag: PHP

  • PHP: get full URL of current page with GET params or without

    The following string variable’s value will get the full URL of the current page, including GET arguments/params, if present.

    To get the full URL of current page but WITHOUT the GET args/params, do this instead:

    The strtok function will return only the part of the URL string up to the character before question mark “?” which is used by GET args/params.

    strtok was suggested in this StackOverflow answer: http://stackoverflow.com/a/4643312

  • PHP: avoid backslash on json_encode

    Hey! 🙂 If you are encoding your Arrays to JSON in PHP using json_encode() and the function adds backslash before your slashes, I’m gonna show you a quick fix.

    This is my original code:

    And the result is:
    {"success":true,"message":"Please enter email\/phone number."}

    See the added backslash before the slash? Ugly, right? To avoid that, simply add the JSON_UNESCAPED_SLASHES argument to your json_encode() function usage like this:

    Try it!

  • Laravel 5: How to change Auth URL from “/auth/login” to just “login”:

    Just sharing a link telling us how to remove the “auth” in the URL for Laravel’s pre-made login system.

    You need to modify App\Http\Middleware\Authenticate::handle() method and change auth/login to /login.

    Then you need to add $loginPath property to your \App\Http\Controllers\Auth\AuthController class.

    Source: How to change default redirect URL of Laravel 5 Auth filter?

  • Laravel 5 Folder Structure, Before and After


    Hey! 🙂 This is a page I’m preparing quickly for developers who are used to the folder structure of Laravel 4 and older, just to serve as reference on where we can find things in Laravel 5 now.

    If like me, you are new to Laravel 5 but have developed apps using older Laravel versions, you might also be a little confused with the new folder structure. Let the following table of data guide you. Don’t worry, after a while, I’m sure you’ll get used to the Laravel 5 folder structure. 🙂

    Find what? Before Laravel 5 In Laravel 5
    routes.php /app/routes.php /app/Http/routes.php
    Controllers Folder /app/controllers /app/Http/Controllers
    Models Folder /app/models usually /app or /app/models
    Views Folder /app/views /resources/views
    Config Folder /app/config /config

    I know, I wrote this Laravel 5 setup tutorial earlier. But I honestly haven’t really gotten used to the changes in Laravel 5 yet because I got caught up in learning Android app development. Not a bad thing though! 😀

  • How to make a basic “Login via Facebook” with PHP & JavaScript

    How to make a basic “Login via Facebook” with PHP & JavaScript

    You’ve seen how some popular websites let you register or login via Facebook — Pinterest, Vimeo, Lifehacker, and many more.

    In this blog post, I’ll show you the very basic setup of the Facebook login button for your website. It is up to you to enhance the functions of your registration system.

    Note: There are periodic updates to the Facebook API, sometimes resulting to issues with previously working implementations of the API. So please note that this tutorial was written in the third week August 2015. 🙂

    I began writing this tutorial late in August, but because of other projects, was able to publish it when it’s already September.

    (more…)

  • Facebook App Development tips, guides, and possible solution to issues

    In July 2013, I began learning about developing apps that run in Facebook. For a web developer especially one who works in a marketing agency, learning about Facebook app development is important nowadays because numerous amounts of campaigns are ran on Facebook.

    At first Facebook app development confused me, but after some exposure to it and some help from colleagues who have been doing it for years, I got the feel of it.

    Following are some blog entries on my Code Playground that are related to Facebook app development. (more…)

  • OpenCart: Override Invoice ID

    Edit: Seems like there’s something missing in the code I inserted. I only found out after further system testing. Will update this post when I feel like fixing it. :p

    I’m taking an E-Commerce class (it’s my last school term!) and my group’s project in an online store that uses OpenCart, an open-source shopping cart software. Our professor wants us to have transaction numbers (invoice ID, in OpenCart) that are not simply the increment of the previous one (0001, 0002, 0003, …).

    It took me long to figure out how to edit the invoice ID that OpenCart generates. In the settings page of the admin area we can only edit the prefix (default is INV) and the starting invoice ID (default is 001). When I change either of the two fields the invoice ID that is generated doesn’t change at all. After some research I found out that (more…)

  • Wrapping text in table cells and DIV tags

    I’ve been doing research on how to wrap texts. First solution I found was giving the CSS property word-wrap the value break-word:

    word-wrap: break-word

    But this didn’t work in Firefox.
    (more…)

  • PHP: Dynamic inclusion tutorial

    I’m posting this because I thought that it might help some people who want to structurize their website in a way that they can easily edit pages which contain contents and pages which contain the code of the layout, as we separate layout code from contents in dynamic inclusion.

    This is for PHP beginners, but I assume that you have basic knowledge about PHP variables and form submission methods if you would read this tutorial.
    (more…)