php

Get number of arguments for a class function.

Hi, Is there a way to detect the number of arguments a function in a class has? What I want to do is the following. $class = 'foo'; $path = 'path/to/file'; if ( ! file_exists($path)) { die(); } require($path); if ( ! class_exists($class)) { die(); } $c = new class; if (num_function_args($class, $function) == count($url_segment...

How to add &ref=123 every link

How would i be able to put the follow on the end of every link of my website with out editing every link? e.g www.WebsiteName.com/?ref=123 so if i went to www.WebsiteName.com/aboutus.php i want it to add ?ref=123 onto the end of the url. ...

SimpleXML get next/prev node

I'm building a photo gallery, building an object based on an xml file. How can I grab the next and previous nodes? Here's what my base code looks like: $xmlData = new SimpleXMLElement(file_get_contents("data.xml")); foreach($xmlData->row as $item) { if ($item->url == $_GET['id']) { // show photo $title = $item->titl...

PHP errors when changing hosts

I've recently inherited a website written in PHP and given the responsibility to move it from the current host to our own internal web servers. I succesfully copied the files and i can browse the site on our webserver (IIS7) however some, not all, of the PHP scripts do not appear to execute properly. For example, the following code l...

Can I sort the contents by stat from the facebook like button?

Is that possible?sould I combine the like number into mysql? ...

PHP - why can't I get rid of this session id cookie?

I'm trying to troubleshoot a logout function for a web app. When you're logged in, the app has several cookies set for its domain. Here's the current logout procedure: You click a link, which sends you to a logout page The logout page runs a function that calls session_destroy() and also loops through all the cookies for the domain and...

What advantages does PHP have over ASP.NET?

I have opened a large web project on elance for a social network. I got over 30 bids on my project and many of the providers recommended php even though they had .net knowledge. many have said that php with drupal has many advanteges over the .NET framework but did not say what they were. Its hard to believe that a scripting language has...

What's wrong with this PHP code to send POST data via a stream?

I'm trying to use a PHP script to login to another web site (a Moodle install, in this case) by POSTING to the login page. This code seems to partially work. The problem is that only the first parameter is recognized by the receiving end. For the code shown below, only the 'username' parameter is recognized. However, if you switch ...

Retaining data in HTML form

I have an HTML form. Let's say I fill out all the fields and submit it (PHP script runs here). Then I want to go back to the form using "Back" button of my browser. What I see is the empty form. What do I do to have the entered data retain on the page after I come back to it using "Back" button of the browser? Thank you! ...

PHP DateTime Inconsistency? What am I missing?

Using PHP 5.2.5 I was working with some DateTime objects and noticed a time that seemed off. The problem I'm having may be related to timezones, but I'm not sure - I'm creating a DateTime from a Unix Time Stamp and getting different/unexpected results depending on how I output it. I created the following to easily illustrate the "issue...

preg_replace on text only and not inside href's

I have this code to do some ugly inline text style color formatting on html content. But this breaks anything inside tags as links, and emails. I've figured out halfways how to prevent it from formatting links, but it still doesn't prevent the replace when the text is [email protected] $text = preg_replace('/(?<!\.)mytext(?!\/)/', '<spa...

PHP: object is NULL right after creation

We have very strange errors occasionally popping up in our php logs: Trying to get property of non-object. This exact error seems to be caused by the access to the member $shortName in the following if statement: class MyLocaleWrapper { … protected static $system = NULL; public static function getSystemLocale() { if...

PHP + Jquery - page move on top after an ajax call

Hi. I make this code that, after 9 seconds, it call an ajax function, and print the result elaborated from the server to the client. This is the JS code : function changeSponsor() { $.ajax({ type: 'POST', cache: false, url: './auth/ajax.php', data: 'id=changespon', success: function(msg) { ...

Conditional .htaccess for URL

RewriteRule ^photographs/?$ photographs.php [L] RewriteRule ^photographs/(.*)/?$ photographs.php?cat=$1 [L,QSA] RewriteRule ^photographs/(.*)/(.*)/?$ photographs.php?cat=$1&page=$2 [L,QSA] I need this to have options such as /photographs /photographs/category /photographs/category/3 Thanks ...

Do .php files without any PHP in them get passed to the interpreter?

On a standard LAMP stack, do .php files without any PHP in them get passed to the PHP interpreter? In other words, is there a performance/processing loss for creating a .php file without actually including any PHP in it, versus just making it a .html file? ...

Bundling Doctrine PHP commonly used models

Doctrine PHP documentation suggests bundling commonly used classes to single files. Does this refer to Doctrine model files? If so , do you have any examples of how this would be done and how you would then load those models? We are using lazy loading so I am curious about how the lazy loader would be able to find out where the various ...

Wordpress create a new post status?

In Wordpress you get the default post statuses: Published, Draft and Pending Review. Is it possible to add some more post types via registering them via the function.php file of the active theme? Also is it possible to edit the lables of the Publish Meta Box? What I'm submitting really isnt Publishing... Also like to add I only want th...

PHP server event handling

Hello. I am looking for a way to have like a button in a web page, only when you press it the event handling is a program in a server. Like a trigger to execute a program in the server. Is there any way to do this? Cumpz. ...

Execute php script only once on live site

Hello, I have a script that does an update function live. I would move it to a cron job, but due to some limitations I'd much rather have it live and called when the page loads. The issue is that when there is a lot of traffic, it doesn't quite work, because it's using some random and weighted numbers, so if it's hit a bunch of times, ...

Send Email from PHP Script.

I wrote some code to send an email from my PHP script using PHPMailer. For some reason, the scripts isn't sending the messages. Here Is My Code: <?php require_once("PHPMailer/class.phpmailer.php"); $mail=new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->Host = "ssl://smtp.gmail.com"; $mail->Port = 465; $mail->Username ...