Skip to content
Advertisement

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

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

Advertisement