In situations where you want to convert the value stored in your variable to ascii code in PHP you can use the following code. function nabascii($input) { foreach (str_split($input) as $obj) { $output .= ‘&#’ . ord($obj) . ‘;’; } return $output; } Call the code by using: $myvariable = “nabeel”; echo nabascii($myvariable); This small […]
Category: Logic
How to remove last (few) characters of a string variable in PHP
If you are in a situation where you need to remove last few (one or two, or even three or so on) characters from a variable using php, then the solution is pretty much simple. Simply use this function to remove any number of desired characters from your string (variable) substr($your-variable,0,-1); In the above function […]
How to check if a website url is valid – PHP
There are various ways of checking if a given variable of website url is valid or not. However most of they try to get content of the webpage or ping it etc. The way that i prefer to use is by fopen command in a function or separately. Use this code to confirm or verify […]
How to remove extension from a file name using PHP
This code can be used to remove an extension from the file name using php. If manipulated abit, it can also be used to find the extension of php and echo it. function RemoveExtension($strName) { $ext = strrchr($strName, ‘.’); if($ext !== false) { $strName = substr($strName, 0, -strlen($ext)); } return $strName; } $Name = ‘file.txt’; echo RemoveExtension($filename); However, in my case, i tried using it with a bunch of […]
How to code custom submit form in php in wordpress
Today I got an sms from my friend regarding some query related to wordpress custom form coding (through plugin or theme directly) . Although i am sleepy while writing this post, I will try to be as much descriptive as I can. Do let me know if anything in the tutorial is ambiguous. The question […]
How to Remove Virtumart Image from Joomla Store (Joomla! 1.5 virtuemart 1.1.4)
NOTE: This article is supposed to be for educational purposes only. This is tested on virtuemart 1.1.4 running on Joomla! 1.5 When we install virtuemart on joomla! it shows the logo for virtue mart on each shop page with link to virtuemart site. Yes, its their right to show it because it’s their script and […]
SI Captcha Issue – CAPTCHA image not displayed
Today i got contacted by a very nice person via my facebook profile regarding this blog. He mentioned that the Captcha image is not being displayed on the blog comments so it was not possible to post any comments. Well i quickly verified that the captcha was really broken! There was captcha image not displayed […]
WordPress Plugin error – Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at / . . .
Today while developing a wordpress plugin, i experienced an error when i activated it. Although the plugin worked as it was expected to, but the error was there and seemed as if my plugin is conflicting with si-captcha for wordpress plugin. The error was: Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already […]
Detect users internet browser (firefox, safari, iphone, ipod, ipad, internet explorer, opera ) and redirect to different page specific to it
Some times we need to detect the browser of the user in order to redirect them to browser specific page, or to do any other task that is related to displaying that website for that particular user’s browser, e.g firefox, opera, internet explorer, safari, or are coming from an iphone or an ipod. Edit: You […]
Restrict script use (number of times per day) using php & mysql
If you are a programmer and want your script to be restricted to say 5 time use only per day, then here is the basic idea about how to do it in this post. Please let me know if you feel any difficulty or need any code example etc too. We need to make a […]