So I have this function: function toAlpha($data){ $alphabet = array(‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’,’l’,’m’,’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’); $alpha_flip = …
Tag: function
PHP function with variable as default value for a parameter
By default a PHP function uses $_GET variables. Sometimes this function should be called in an situation where $_GET is not set. In this case I will define the needed variables as parameter like: actionOne(234) To get an abstract code I tried something like this: which results in an error: Parse error: syntax error, unexpected T_VARIABLE Is it impossible to
How do I display a wordpress page content?
I know this is really simple but it just isn’t coming to me for some reason and google isn’t helping me today. I want to output the pages content, how do I do that? I thought it was this: Answer @Marc B Thanks for the comment. Helped me discover this:
PHP: a short cut for isset and !empty?
I wonder if there any better ideas to solve the problem below, I have a form with a number of input fields, such as, But sometimes don’t need certain input fields above in my form, for instance, I only need the page title for my db injection, And I have another php page to handle the $_POST data, Every time
Problem return a function inside of a shortcode in WordPress
I have some trouble coding a themes shortcode. I want the code to display a div with a view counter function, and then a link with the shotcodes content as the url. The view_count(); function works fine when called inside theme files, and I actually managed to make it show, but then it displayed before the_content(); of the post (the
Codeigniter variables from constructor are undefined
I’m using CI’s Auth Tank library to query records for certain users. The variable $user_id = tank_auth->get_user_id(); grabs the user id from the session. I want to pull records where user_id = $user_id. From what I understood, constructors can load variables each time a class is initiated. Sort of like global variables. So I figured I’ll set my $user_id in
PHP append one array to another (not array_push or +)
How to append one array to another without comparing their keys? At the end it should be: Array( [0]=>a [1]=>b [2]=>c [3]=>d ) If I use something like [] or array_push, it will cause one of these results: It just should be something, doing this, but in a more elegant way: Answer array_merge is the elegant way: Doing something like:
PHP Fatal error: Using $this when not in object context
I’ve got a problem: I’m writing a new WebApp without a Framework. In my index.php I’m using: require_once(‘load.php’); And in load.php I’m using require_once(‘class.php’); to load my class.php. In my class.php I’ve got this error: Fatal error: Using $this when not in object context in class.php on line … (in this example it would be 11) An example how my
How find the source code for an eval’d function in PHP?
I am trying to find a way to get the source code for (user defined) PHP functions in a string. For normal code this is easy, using reflection I can find the file and line numbers where the function is defined; then I can open the file and read the function source code. This will not work if a function