Does anyone know if doing this
foreach ($user->getFriends() as $friend) {
// Do something.
}
Causes PHP to call the function getFriends() on the user object multiple times and thus would this be more efficient?
$friends = $user->getFriends();
foreach ($friends as $f) {
// Do something.
}
...
Hi,
I'm an absolute newbie to EC2. My goal is to run a php-mysql-website on EC2.
I've just setup a new instance based on this ami
It seems that apache isn't running? How do I start apache? Is there a general tutorial on how to start EC2 as a web server?
Thanks!
...
Hello all,
I am finding a line in a PHP file using PHP and writing to it by changing a variable at a particular line. Please see function below.
This works fine when I test it on its own. However, when I run it within my main script it doesn't work properly. I find the following sort of thing on = "Version_3_18110"; in the PHP file whe...
Are regex's allowed in PHP switch/case statements and how to use them ?
...
I have a PHP server listening on port 5001 and 127.0.0.1
$socket = stream_socket_server("$host:$port", $errno, $errstr)
It work fine when a client in php connects to the server, but the same fails if a client written in C tries to connect.
I have updated firewall settings, just unable to resolve the issue. Is there a different way t...
Having used Haml and Sass for a few Rails side projects, I've found that they speed up my frontend development tremendously. However, I haven't found a Rails blogging platform that's as robust or familiar to clients as Wordpress, so that's still generally my go-to for projects that require a light website with basic CMS / blogging funct...
Possible Duplicate:
Can I include code into a PHP class?
Hello,
I have some third-part php files that I would like to include as classes in my application. The problem is those files keep changing and they are not OOP, just a bunch of functions. To keep them updated and to work in my framework I have to use them in a class, s...
I'm trying to create a function that does a text replacement on the post content when its saved (the_content).
The stub function is below, but how do I obtain a reference to the post content, then return the filtered content back to the "publish_post" routine?
However, my replacement is either not working and/or not passing the update...
Why this code doesn't work?
public function get($key) {
return isset($_SESSION[$key]) ? &$_SESSION[$key] : false;
}
Error
Parse error: syntax error, unexpected '&' in C:\Arquivos de programas\EasyPHP-5.3.3\www\myphpblog\code\sessionstorage.class.php on line 12
Thank you.
...
I want to search the text property of my twitter status objects and swap out @username for <a href="http:/twitter.com/username">@username</a>. What I have tried so far looks like this:
$pattern = '/([@]{1})([a-zA-Z0-9\_]+)/';
$replace = '<a href="http://twitter.com/\2">\1\2</a>';
$new_string = preg_replace($pattern, $replace, $...
Yes, I have an issue.
I have my upload profile picture.
1) A popup comes up
2) you upload a image
3) you crop it
4) you press finish, and you get it as your new profile photo (the original uploaded image will be replaced with the cropped one, so the original image will be removed, and will not take any space)
Now if the users can...
I have a PHP app where I can upload files. When I upload most files and do a print_r($_FILES), I get something like this:
Array
(
[import] => Array
(
[name] => Array
(
[excel_file] => COD MKTG 2.csv
)
[type] => Array
(
...
How to make regular expression in PHP? Can anyone guide me to the basic rules to make regular expressions?
...
Here is the error message:
Fatal error: Call to undefined function mysql_connect() in /var/www/config.php on line 10
Below is the code:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
include('config.php');
// table name
$tbl_name=temp_members_db;
// Random confirmation code
$confirm_code=md5(uniqid(rand()...
Hi Gang,
Brain totally not working today.
So, I have a few columns in a table that basically designate whether a certain piece of information WAS or WAS NOT provided by the user.
For example, I have a table with:
| ID | USER | crit1 | crit2 | crit3 | crit4 | etc. |
Now, the record could have a 1 or yes for any of the "critX" fields...
I am running a shell script in the background and redirecting the output to a log file in php. I want to display the contents from the log file on the page. I am able to do that using the code below.
<?php
$logfile = "hello";
?>
function displayOutput()
{
var html = <?php
echo filesize($logfile)
? json_e...
Hi Folks,
So my user signs up from the Android App on his phone and after sign up is successful I trigger a mail to be sent to the signed up email address with an Activation Passcode from my PHP script. Here is the line of code that I use which is pretty trivial.
mail($to, $subject, $message, $headers);
The mail is sent correctly eve...
I need to do a huge replacement on my site 400+ items with the new asynchronous tracking.
pageTracker._trackEvent('footer_search', 'search', 'search-footer');
Im using aptana and it has a regex replacement, it needs to look like this, notice the [ ].
_gaq.push(['_trackEvent', 'footer_search', 'search', 'search-footer']);
Much appr...
Hi, recently I had a job interview. I had two tasks:
1) to refactor a JavaScript code
// The library 'jsUtil' has a public function that compares 2 arrays, returning true if
// they're the same. Refactor it so it's more robust, performs better and is easier to maintain.
/**
@name jsUtil.arraysSame
@description Compares 2 arrays, re...
How can I use something like jQuery & PHP to reorder elements within an xml file?
The jQuery plugins below allow html table rows or list items to be swapped about, but I have no idea of how to save those changes back to an XML file with the click of a button.
www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/
www.jqueryui.com/d...