I want display the content of doc file in a textarea for my project using PHP as it is means line break, font size etc.
Any code or how to do it. And i will be fetching that doc file from database.
Take a look at this example, and notice the outputs indicated.
<?php
class Mommy
{
protected static $_data = "Mommy Data";
public static function init( $data )
{
static::$_data = $data;
}
public static function showData()
{
echo static::$_data . "<br>";
}
}
class Brother extends Mommy
{
}
class Sister extends Mommy
{
}
Brother::init( "Brother Data" );
Sister::init( "Sister Data" );
Brother::showData(); // Outputs: Sister Data
Sister::showData(); // Outputs: Sister Data
?>
My understanding was that using the static keyword would refer to the child class, but apparently it magically applies to the parent class whenever it is missing from the child class. (This is kind of a dangerous behavior for PHP, more on that explained below.)
I have the following two things in mind for why I want to do this:
I don't want the redundancy of defining all of the properties in all of the child classes.
I want properties to be defined as defaults in the parent class and I want the child class definition to be able to override these properties wherever needed. The child class needs to exclude properties whenever the defaults are intended, which is why I don't define the properties in the child classes in the above example.
However, if we are wanting to override a property at runtime (via the init method), it will override it for the parent class! From that point forward, child classes initialized earlier (as in the case of Brother) unexpectedly change on you.
Apparently this is a result of child classes not having their own copy of the static property whenever it isn't explicitly defined inside of the child class--but instead of throwing an error it switches behavior of static to access the parent. Therefore, is there some way that the parent class could dynamically create a property that belongs to the child class without it appearing inside of the child class definition? That way the child class could have its own copy of the static property and the static keyword can refer to it properly, and it can be written to take into account parent property defaults.
Or is there some other solution, good, bad, or ugly?
Hi guys,
I'm working my way through some tutorials. I see the Zendcasts tutorials have me setting up a lot of things in the bootstrap.php file, while with the quickstart and other tutorials, don't even touch that file and do a lot of changes in the application.ini file.
What is the difference between the two and why use one over the other?
Thanks!
What is better for PHP developer - Unicode or UTF-8?
I am going to create international CMS. So I am going to have clients all over the werld. They will speak all posible languages.
What encoding format is better for browser recognition and for DB data storing?
I consider myself quite fluent in PHP and am rather familiar with nearly all of the important aspects and uses, as well as its pratfalls. This in mind, I think the major problem in taking on Perl is going to be with the syntax. Aside from this (a minor hindrance, really, as I'm rather sold on the fact that Perl's is far more readable), what are some key differences you think I should make myself aware of prior to taking on the language?
I doubt if this is encryption but I can't find a better phrase. I need to pass a long query string like this:
http://test.com/test.php?key=[some_very_loooooooooooooooooooooooong_query_string]
The query string contains NO sensitive information so I'm not really concerned about security in this case. It's just...well, too long and ugly. Is there a library function that can let me encode/encrypt/compress the query string into something similar to the result of a md5() (similar as in, always a 32 character string), but decode/decrypt/decompress-able?
Hi, does anyone know of a known method in PHP to auto connect to MySQL db/table in case an app is using multiple databases on multiple hosts?
Question 1: are there scripts around that allow to auto connect to necessary host/DB based on query?
Question 2: if above is not possible, is there a known approach to properly passing host/DB info to make sure app is properly connected before executing the query?
In PHP I'm running a mysql_query that has an ORDER BY clause. I'm then iterating through the results to build an associative array, with the row_id as the key.
Then, I'm calling json_encode on that array and outputting the result.
This page is loaded with AJAX, and defined in a Javascript variable. When I iterate through that Javascript variable, will I still have the order that was returned from the mysql_query?
It seems like I can't use shell_exec or proc_open on my shared server.
The message I get when I try to use it is:
Warning: shell_exec() has been disabled for security reasons in /home/georgee/public_html/admin/email.php on line 4
Are there any alternatives to these functions?
Problem: I want to determine the original file creation time from a file uploaded to my server via PHP.
My understanding is that the file is copied from the client to a temporary file on my server, which then is referenced in the $_FILES var. The temporary file is of course of no use because it was just created. Is there any way I could get the creation date from the clients original file?
Thanks
Hi..
I need to use include Function with variable.
but,when I try to do it I faced some errors .
Code :
$year=$_POST['year'];
$month=$_POST['month'];
$day=$_POST['day'];
include "Event.php?year=".$year."&month=".$month."&day=".$day;
so,can U help me ? : )
So I know that my server on real form submit turns %CE%EB%E5%E3+%DF%EA%F3%F8%EA%E8%ED into ???? ??????? . How to peform string transfer from ???? ??????? into %CE%EB%E5%E3+%DF%EA%F3%F8%EA%E8%ED using ActionScript? (Its ok if a space character as %20, not + , PHP should handle that fine.)
My site is having around 100+ constants defined and this can potentially reach 200.
I'm using define() for defining constant.
Will this cause a performance hit ?
How many max constants can i define in PHP ?
Is it possible to translate everething written in OCaml to PHP? for example will it be hard to translate such lib as lib for Fast content-aware image resizing
So I've read the two related questions for calculating a trend line for a graph, but I'm still lost.
I have an array of xy coordinates, and I want to come up with another array of xy coordinates (can be fewer coordinates) that represent a logarithmic trend line using PHP.
I'm passing these arrays to javascript to plot graphs on the client side.
I have a php application running on XAMPP but I want to connect to a mysql db running on a remote machine(which is also using XAMPP). The application works fine when I connect to the mysqldb instance on my machine. I have changed the configuration files to point to the remote db and have given the correct credentials as well. But I get access denied error.
One from here:
$sth->execute(array(':calories' => $calories, ':colour' => $colour));
The other from here:
/*** reassign the variables again ***/
$data = array('animal_id'=>4, 'animal_name' => 'bruce');
/*** execute the prepared statement ***/
$stmt->execute($data);
My question is: :key or key ?
Sorry I don't have the PHP environment here.
What can I do to make my PHP web application fail in a more noisy way?
I am using an MVC pattern and often when classes fail to load or failures they do so without error.
I want to be able to get the size of a file before uploading it to a PHP script using FileReference.
Can I get the file size before detecting bytesTotal during the upload process?
PHP, Cold Fusion, and ASP (among many others) are usually sold on their strengths. What are their weaknesses? If one were to develop a niche product to handle the things that these products weren't so good at, what should it focus on?
Hi everyone,
I have recently heard a lot of people argue about using PHP testing features like PHPunit and SimpleTest together with their IDE of choice (Eclipse for me). After googling the subject, I have still a hard time understanding the pros and cons of using these testing frameworks to speed up development.
If anyone could explain this for me in a more basic level, I would really appreciate it. I am using PHP5 for the notice.
Thanks a lot!
I have an array called $times. It is a list of small numbers (15,14,11,9,3,2). These will be user submitted and are supposed to be minutes. As PHP time works on seconds, I would like to multiply each element of my array by 60.
I've been playing around with array_walk and array_map but I can't get those working :S
Thanks.
I'm using the Markdown library for PHP by Michel Fortin. I started noticing that it formats the text in tags with markdown rules, like so:
http://foo.com/My_Url_With_Underscores
essentially becomes:
<a href="...">http://foo.com/My<em>Url</em>With_Underscores</a>
How do I disable that behavior or otherwise prevent the library from doing that?