function parent($key)
{
function son()
{
global $key;
}
}
I want to achieve this:
son can access the $key of parent
As it's quite a simple function,I don't want to change parent into a class
OK,I've been told that function are global anyway.Is there a way for son to get $key of parent then?
...
So I have a menu in a php file that looks like this (This is the whole file. I'm totally new to PHP.)
menu.php:
<li id="current"><a href="#"><span>Home</span></a></li>
<li><a href="http://blog.me.net/"><span>Blog</span></a></li>
<li><a href="http://www.me.net/R"><span>Results</span></a>...
I want to calculate whats the date 20 yrs back from current time in php.How can do that.I am not able to figure this out in a proper manner. Scenario is:
I am having a column dob in mysql. Now i want to retrieve all the users who age is more than 20yrs and less than 25 yrs.
I am using doctrine orm
Edit
Its working fine but giving a w...
So I'm trying to debug my website... basically what I need to do is write a script that will periodically follow a link on my page, but I need to see the result in my browser which is why I need it to happen in the browser. I want it to click on the same link every few seconds without any human interaction.
The resulting page each time w...
Hi,
I have a regular expression for matching URIs:
eg: preg_match("/^my\/uri\//i", "my/uri/whatever");
which I use for routing:
eg: "http://www.mywebsite.com/my/uri/page.html" will match the above (with the protocol/host removed of course)
now I was wondering if there was any way to evaluate the regular expression into the most gener...
WordPress spits posts in this format:
<h2>Some header</h>
<p>First paragraph of the post</p>
<p>Second paragraph of the post</p>
etc.
To get my cool styling on the first paragraph (it's one of those things that looks good only sparingly) I need to hook into the get_posts function to filter its output with a preg_replace.
The goal is ...
Hello,
I want to display the image actual view when the mouse is over the thumb sized image. But when the mouse is placed over the first image it appears and then disappears, not the case with the second and following images.
It works perfectly fine in IE, but not in FF or Chrome.
$file - runs displays all the files in a directory
$i...
Magento has a large code base (6000+ php files), uses a complex autoloading logic, and has a lot of configuration in XML. I'm looking for an IDE that can get it's little brain around this code base - show me where a function is declared, where it's called, etc. Is there any IDE that can handle this beast?
EDIT - Adding examples
Here...
How do strip all regex special characters from a string?
eg: I have "/^bla\/bla\/bla\//i" which I want to be: "bla/bla/bla/"
...
If i had the following text in a string:
<h4>Tom</h4>
<p>One Paragraph</p>
<p>Two Paragraph</p>
What code would i need to parse on that string to get an output like this (if i didnt know what was inside the <h4> tag?
<p>One Paragraph</p>
<p>two Paragraph</p>
Thanks!
...
I have been given a task to enable existing Invision Power Board Forum to update Twitter account whenever a new topic is created.
I should probably mention that I've already done this to other custom CMS software of the same client. And because it was custom built software it was possible to hack the code.
In this particular task that ...
I am using rename() to move a file from one folder to another with php.
It works fine with folders which don't have the swedish å ä ö characters involved.
Is there any way around this? (except for changing the folder names to something without special chars)
The website is entirely in utf-8 format...
...
What is more efficient and/or what is better practice. To echo the html or the have many open and close php tags?
Obviously for big areas of html it is sensible to open and close the php tags. What about when dealing with something like generating XML... should you open and close the PHP tags with a single echo for each piece of data or...
<?php
function getPosts($showposts,$tags, $thumb_key="thumb_300x166", $thumb_class, $thumb_width="300", $thumb_height="166") {
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('tag=$tags&showposts=$showposts');
while ($wp_query->have_posts()) {
$...
I am using a php function that will return 2 arrays.below is my function
function imserv($id){
$xml=simplexml_load_file("feed.xml");
$images=$xml->xpath('//IMAGE');
$services=$xml->xpath('//SERVICES');
return array ($images,$services);
}
i use the below code to get results from the services block
$services=imgserv('5874');
foreac...
Hello
I have 3 tables:
category doesnt matter
item2cat: itemID|catID
item: id|name|desc
I want to list the items that are in the given category, but I don't know how to do it in a simple way. (With PHP and MySQL)
I need this table-structure because I want multiple categories to one item.
...
i am including a path to an image like this:
$msg.='<img src="http://my.test.ca/images/show.jpg" width="75" height="75" />'
in my sendmail function.
the path works and the image is in the specified folder.
here is what happens to the image src when i get the email:
http://my.test.ca/images/sh%20w.jpg
it sorts of breaks the image. ...
I'm using constants for output messages in different languages.
For example, if a user chooses "English", a file with this constant would be required:
define('welcomeMessage','Welcome!');
If she chooses "Spanish":
define('welcomeMessage','Bien Venidos!');
etc etc...
The problem occurs when a user iterates through languages. I can...
AddPage() in tcpdf automatically calls Header and Footer. How do I eliminate/override this?
...
Do I really have to do this to reset an array ??
foreach ($array as $i => $value) {
unset($array[$i]);
}
EDIT:
this one makes more sense, as the previous one is equivalent to $array=array();
foreach ($array as $i => $value) {
$array[$i]=NULL;
}
...