I am connecting to a remote website via sockets. I am expecting a specific string 'XXX' from the remote site. Upon receipt of the string, I want to send back an 'ACK' 200 OK response back to the remote server.
This is what I have so far (assume socket successfully opened);
$fp is resource (pointer) to the socket:
while (!feof($fp)) {
...
If I have two classes that each extend a common parent, is it possible to convert between them?
class Foo
{
public $bar;
}
class FooDatabase extends Foo
{
public function load() {}
public function save() {}
}
class FooFlatfile extends Foo
{
public function load() {}
public function save() {}
}
$foo = new ...
I'm converting a .net app to php. What would be the php equivalent of int(6.22555445656) in php?
...
I have a php script that will loop until all the skill, exp and rating variables are displayed that the user entered into the database.
What I want is the following code to only display once and only if the variables are holding info and not empty. How can I do this. I hope I explained it okay.
I want this code displayed first.
echo '...
I'm storing recurring events in an events table that take place during certain months of the year, any year and every year. For instance;
CREATE TABLE events (
event_id tinyint(3) unsigned NOT NULL auto_increment,
name varchar(255) NOT NULL,
month_from tinyint(3) unsigned NOT NULL,
month_to tinyint(3) unsigned NOT NULL,
P...
Hello, everyone
One site was moved to another server where is installed Solaris and other iconv settings. Now, when I validate anythink with "StringLength" function from Zend Framework my scripts fail with this error:
Notice: iconv_strlen() [function.iconv-strlen]: Wrong charset, conversion from `UTF-8' to `UCS-4LE' is not allowed in /...
Im currently calling a php code that displays results from a mysql db by using AJAX so that the page doesnt reload!
Inside the php code, I am creating a menu where the users can chose to display only "private ads" or "all ads".
Currently, "all ads" are displayed in a div container using ajax as mentioned because I havent implemented th...
I mostly a .NET developer but need to do some new work in Drupal.
So I guess I need a portable
- Apache
- PHP
- MySQL
- phpMyAdmin
- Drupal codebase
What is the best way to work with the environment on a portable / thumb drive? I'm on Windows.
I want to go portable because I work on 3 to 4 different machines throughout the week.
Is...
This may sound like a frivolous question, but those in the security field will get it. Should I let the user enter any number of characters as long as it's greater than 0 chars. My logic is:
the password is going to be hashed and salted anyway, and
it's more fun for someone doing a rainbow table to NOT have any length/other guideline...
I was working on project that had problem when encoding UFT-8 text into JSON Format
<?php
$result = array('wine'=>"测试", 'عربي'=>4, 'lemon'=>22);
echo json_encode($result);
and i also tried Zend_JSON Library ,
<?php
require_once 'Zend/Json.php';
$result = array('wine'=>"测试", 'عربي'=>4, 'lemon'=>22);
echo Zend_Json::encode($r...
Hello, I need to preg_match for
src="http:// "
where the blank space following // is the rest of the url ending with the ". My adapted doesn't seem to work:
preg_match('#src="(http://[^"]+)#', $data, $match);
And I am also struggling to get text that starts with > and ends with EITHER a full stop . or an exclamation mark ! or...
instead of
login.php?ref=http://mysite.com/lastpage
could I get the before page somehow else? tried HTTP_REFERER but cant get it to work
Notice: Undefined index: HTTP_REFERER in C:\test\login.php on line 18
// Newbie
...
Hi there!
I'm trying to get file contents, replace some parts of it using regular expressions and preg_replace and save it to another file:
$content = file_get_contents('file.txt', true);
$content_replaced = preg_replace('/\[\/m\]{1}\s+(\{\{.*\}\})\s+[\x{4e00}-\x{9fa5}]+/u', 'replaced text', $contents);
if ($content_replaced) {
fi...
I am currently using the following PHP code generate a Select Box with different times:
<?
for ($x = 28; $x < 81; $x++) {
if ($x == 48) {
print "<option selected='selected' value='" . date("H:i:s", mktime(0, $x * 15, 0, 0, 0)) . "'>" . date("g:i a", mktime(0, $x * 15, 0, 0, 0)) . "</option>";
}
else {
print "<option value...
I have a class in PHP like so:
class ParentClass {
function __construct($arg) {
// Initialize a/some variable(s) based on $arg
}
}
It has a child class, as such:
class ChildClass extends ParentClass {
function __construct($arg) {
// Let the parent handle construction.
parent::__construct($arg); ...
I need to process an email inbox, monitor it for messages with a particular subject line. If it finds a match I need to get the body content, manipulate, and insert into a database. Ideally would mark the message as read and move it to another IMAP folder as well.
I'm poking around PHP documentation imap_open (http://us2.php.net/imap%...
I am writing this comment class:
class Comment {
public $id;
public $post_id;
public $name;
public $email;
public $website;
public $body;
public $date;
public $ip_address;
public $status;
function __construct($id) {
global $db;
$resc = $db->query("SELECT * FROM blog_comments WHERE id...
I would like to create new contacts and leads using php. I can't quite figure out how to call the methods of the mscrm 3 web service.
The php soap class seems quite simple to use. I am able to connect and authenticate to the crm web service and get a list of available functions however I am unsure how to go about calling them.
I have...
Hello,
I am looking for qa tools for php. I am used to pmd, findbugs and checkstyle in the java world. Do you know some similar tools for php doing code analysis ?
So far I have found but not tested yet :
phplint
pmd's cpd module
PHP_CodeSniffer
Thanks in advance for your help
...
I want to create a script in php to read al mail from a mail acount. I connect to the server, I can see the mails but went I want to seet it back to unseen I can't find a function to do this.
...