Quantcast
Channel: Question and Answer » variables
Browsing index pages (37 articles)
↧

Using variable in two functions

What would be the right way of using variable with same data in two functions? Is next approach good practice? I have a few of these variables set up in functions.php $a = array('asdf', 'asdf',...

View Article


Passing variable from child theme function to parent theme filter

I want to pass a variable from my child theme function to a filter which resides in my parent theme. Please let me know whether below code will work or not ? Is it the right way ? Code in Parent...

View Article


Can't access a variable defined in another template despite using GLOBAL

I created, populated and successfully echoed a variable x in header.php. Then in my front page template I did global $x then echo $x. This displays nothing. Why?

View Article

ACF allow zero as a value

I would like to have 0 to 5, and “n/a” as possible values, however this code will output “n/a” when I want it to output a zero. How can I get it to output “0″? (“n/a” is the placeholder if no value is...

View Article

What is the impact of re-defining a dynamic type variable (such as in PHP)?

PHP variables are dynamic in type so I can do: $x = 'hello world!'; $x = strlen($x); Sometimes this is trivial and I could save many lines of code, but it reduces clarity. I’m using a text editor, but...

View Article


Image may be NSFW.
Clik here to view.

What is internal state and is there a difference between state and internal...

Ok, this question has been asked before, but it’s still not clear to me. What exactly is internal state? So far state is clear to me: Functions contain behavior, variables have state, values don’t. So...

View Article

Get WordPress Page Title, ID, or Template of the Page an AJAX Request is Made...

I have a page template that includes a region that holds links to a series of video custom post types. Each of the links is tagged with an ‘ajax-link’ class so that through an AJAX request I can pull...

View Article

Dynamically adding filters

I have a function that I’m trying to get an array in it to use in a callback to dynamically add filters. Here is the function that I need to retrieve the array keys from ( in the $classes variable ):...

View Article


Avoid This Pointer

PROBLEM: this points to different instances at different stages of execution (as it should). But it is not always obvious which instance is that. On the other hand we could minimize the use of this,...

View Article


What is the use case for shadowing variables?

One of the things the coffeescript programming language is criticized for is its treatment of variable declarations and scope (example). The answers to this question (and the blog I linked to above)...

View Article

Using compound statements (“{”…“}” blocks) to enforce variable locality...

This question already has an answer here: Is the usage of internal scope blocks within a function bad style? 4 answers

View Article

Passing attributes to shortcode dynamically

Can I pass dynamically to shortcode attributes like as the following example shows [ authoorsposts author = get_the_author_id(); ]

View Article

How to fix Uninitialized string offset: error on a checkbox in WP Settings API

I am trying to create an options page with a checkbox field. The checkbox is working fine but when I uncheck it and save settings, an error string shows on Notice: Uninitialized string offset: 0 in...

View Article


What was the reason for the creation of boolean variables?

I found out that some languages like C don’t have support for boolean variables and programmers use integers with values of 0 and 1 instead. Is there any specific reason why some languages moved away...

View Article

Best practices for tracking multiple pieces of data in a program

I have a project in C (don’t ask why but it needs to be in C), where I need to track multiple pieces of data and commands for different modules. Some actions that the program will take depend on the...

View Article


Woocommece Variable Product Dropdown hide other two dropdown [closed]

I am using wordpress woocommerce.Here i have question about variable product for woocommece.Here in woocommerce initially all drop down options load.Now is this possible to load it based on first...

View Article

Custom Taxonomy Link Text Echo Name Not Slug

I’m a little lost about where I can place a simple php echo within a loop. I have a “program” taxonomy where each program is echoed onto buttons. Right now I’m only echoing the slugs for the link text....

View Article


How can I see a varibles value when my plugin runs?

I am trying to make a plugin that redirects a user based on how they fill out a form. I am having trouble finding my problem I have narrowed it down to a small snippet that seems to work. function...

View Article

Using a PHP loop or MySQL table for arrays values

I have the following results page from the previous form: <?php //Get the form results (which has been converted to an associative array) from the $_POST super global $musicgenres = $_POST['music'];...

View Article

In C++, should I ever declare a local variable in the corresponding header?

So for example, I create a class with two functions: foo.h class foo { public: foo(); void bar(); void ey(); bool m_memberBool; bool localBool; // ??? Should I put this here? }; foo.cpp #include...

View Article
Browsing index pages (37 articles)


Latest Images