Skip to content

Tag: php

Running php script (php function) in linux bash

How we run php script using Linux bash? php file test.php test.php contains: Answer From the command line, enter this: Make sure that filename.php both includes and executes the function you want to test. Anything you echo out will appear in the console, including errors. Be wary that often the php.ini for Ap…

php regex number and + sign only

I need a php function to validate a string so it only can contains number and plus (+) sign at the front. Example: +632444747 will return true 632444747 will return true 632444747+ will return false …

PHP – assign value of function to class constant

In PHP when you define a class level constant as in: const MY_CONSTANT = ‘hello constant’; Why can’t you initialize this value with a function such as const MY_FILEPATH = dirname(dirname(__FILE__)) . …

Remove style attribute from HTML tags

I’m not too good with regular expressions, but with PHP I’m wanting to remove the style attribute from HTML tags in a string that’s coming back from TinyMCE. So change <p style=”…”>Text</p> to just vanilla <p>Test</p>. How would I achieve this with s…

Sanitizing HTML input

I’m thinking of adding a rich text editor to allow a non-programmer to change the aspect of text. However, one issue is that it’s possible to distort the layout of a rendered page if the markup is incorrect. What’s a good lightweight way to sanitize html? Answer You will have to decide betwe…

Can I test paypal api’s from localhost

UPDATE 1: According to this tutorial on Using PayPal’s Instant Payment Notification with PHP, PayPal cannot access locally hosted websites unless certain router ports are opened. Is this because the website is about IPN or is this true for all PayPal APIs? ORIGINAL QUESTION: On my laptop, I have a LAMP …

SSL Connection Reset

I am attempting to connect to an HTTPS endpoint in Java. Every method I have tried (more details below) ends up generating this stack trace: I have tried: Connecting with the javax SOAP libs and a new URL(“https://…”) Connecting with new URL(“https://…”).openConnection() Cr…

jQuery WYSIWYG Reccomedations

I am looking for a WYSIWYG editor that matches a few requirements. ability to customize toolbar ability to customize styles of headings/paragraphs, extra styles in dropdown, etc ability to upload image (to a pre-defined folder on the same server. I do not want a full fledged file manager, just a “select…