Decode uri in php12/28/2023 ![]() PHP URL encoding - base64_encode to the rescue I knew I couldn't change the data, and I knew I needed to pass that URI string to the CakePHP controller, when I remembered my friend, the PHP base64_encode function, and the PHP URL encode technique. ![]() As you might guess by looking at it, trying to pass a raw URI string to a controller (with characters in it like the forward-slash character("/")) would have driven CakePHP nuts. ![]() In fact, because of the data at hand, the only thing I had was a string - and that string happened to be a URI (i.e., something like /foo/bar/baz). But when I went to make the column a hyperlink, I realized I didn't have something like an id field I could use as a parameter to my CakePHP controller call. I was working on a CakePHP web application yesterday when I ran into an unusual problem: I was displaying data in a table in an index page, and I wanted to turn one of the columns of text into a hyperlink to a detail page. Please see the Comments section below for the correction for this problem. The PHP base64 encode algorithm can return a string with the "/" character in that string. ![]() My PHP URL (URI) problemĬorrection: While this article shows how to properly call the PHP Base64 encode and decode functions, the basic premise of removing the "/" characters from the URL, as discussed next, is not correct. Here's a quick look at a problem I ran into yesterday using CakePHP, and how the PHP base64_encode and base64_decode functions helped me encode a URL (URI) and bail me out of my predicament. PHP FAQ: Can you share an example of the PHP Base64 encode and decode functions?Įvery once in a while when you're working on a web application you'll run into data that can cause you some problems, and when that happens, the PHP base64_encode function can come to your rescue. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |