php4

__construct() { issue for PHP4 and PHP5. maybe an another reason

耗尽温柔 提交于 2019-12-11 21:55:41
问题 I have weird issue with CodeIgniter, here is a start part of my controller class Home extends Controller { /** * Constructor */ public function __construct() { parent::Controller(); } ... everything is working fine at localhost, but when I try same at server, I come cross with an error like below: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home3/blabla/public_html/blablabla/applications/frontend/controllers/home.php on line 22 I

What is the difference betwen Variable in PHP4 and PHP5?

筅森魡賤 提交于 2019-12-11 19:53:37
问题 the only thing i know about this subject is... in PHP 5, when a variable used without assigned any value, then it a warning will be shown. Is there any other difference between this 2 different version ? 回答1: There is no general difference between variables in PHP 4 and 5. What you are probably referring to is the ´E_NOTICE` error reporting level. When that level is turned on, PHP will complain if a variable is used that hasn't been assigned yet. That level existed in PHP 4 already: // Report

Porting PHP5 to legacy PHP4, DOMDocument quibbles

瘦欲@ 提交于 2019-12-11 14:56:47
问题 I'm trying to make some of my php5 code work on a legacy server, which unfortunately cannot be upgraded (client's machine). if (!isset($docRoot)) { $docRoot = $_SERVER['DOCUMENT_ROOT']; } // generic storage class for the words/phrases $t = new stdClass(); $t->lang = $curPage->lang; // load xml translations, could split this into different files.. $translations = new DOMDocument(); $translations->load($docRoot."/xml/translations.xml"); $words = $translations->getElementsByTagName("word");

Intern working for Indian NGO - Help with PHP 4, advising staff

假装没事ソ 提交于 2019-12-11 04:05:41
问题 For the past three months I've been working for an Indian NGO, doing some volunteer work in the field but also trying to improve their website, which needs a ton of work. Recently I've been trying to fix the "subscribe to newsletter" button, which is broken. I used filter_var to filter the email input, but when I tried to test this out I got an error. Then I learned that the web host is still using php version 4.3.2 and register_globals is turned on. I've mentioned that they should upgrade

Is there a way to emulate PHP5's __call() magic method in PHP4?

大憨熊 提交于 2019-12-11 03:54:18
问题 PHP5 has a "magic method" __call() that can be defined on any class that is invoked when an undefined method is called -- it is roughly equivalent to Ruby's method_missing or Perl's AUTOLOAD . Is it possible to do something like this in older versions of PHP? 回答1: The most important bit that I was missing was that __call exists in PHP4, but you must enable it on a per-class basis by calling overload() , as seen in php docs here . Unfortunately, the __call() function signatures are different

How to round a decimal number to nearest 5 or nearest 10 in php

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 00:34:54
问题 How to round a decimal number to nearest 5 or nearest 10 in php 回答1: $new = round($num / 10, 0) * 10 rounds to nearest 10 回答2: For the special case of nearest 10, you can use a negative precision: $new = round($num, -1) 回答3: Multiply by 2, round to the nearest 10 (see pascal's answer), then divide by 2. Avoid dividing/multiplying by 5 to do this since float representation will interfere with the accuracy of your results. 来源: https://stackoverflow.com/questions/3308247/how-to-round-a-decimal

How could I parse gettext .mo files in PHP4 without relying on setlocale/locales at all?

帅比萌擦擦* 提交于 2019-12-11 00:16:30
问题 I made a couple related threads but this is the one direct question that I'm seeking the answer for. My framework will use Zend_Translate if the php version is 5, otherwise I have to mimic the functionality for 4. It seems that pretty much every implementation of gettext relies on setlocale or locales, I know there's a LOT of inconsistency across systems which is why I don't want to rely upon it. I've tried a couple times to get the textdomain , bindtextdomain and gettext functions to work

Client does not support authentication protocol requested by server

吃可爱长大的小学妹 提交于 2019-12-10 16:16:03
问题 I need to establish PHP4 environment in conjunction with mysql5 and I am facing this problem when I try to connect to mysql. Thank you for any trace. 回答1: The solution is to update the database user’s password using the OLD_PASSWORD function of MySQL. For example: [chris@office ~]$ mysql -u root -p mysql Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end

PHP4 vs. PHP5 [closed]

纵饮孤独 提交于 2019-12-10 10:17:14
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I have a site that is written completely in PHP4 - the supported version on my hosting at the time. After tons of time on this language, I've come to see that PHP5 has a lot of stuff that I think would be useful to me. Two questions: Would switching my hosting to PHP5 cause any

PHP: Define function with variable parameter count?

元气小坏坏 提交于 2019-12-09 14:48:19
问题 Is there a way to define a function in PHP that lets you define a variable amount of parameters? in the language I am more familiar with it is like so: function myFunction(...rest){ /* rest == array of params */ return rest.length; } myFunction("foo","bar"); // returns 2; Thanks! 回答1: Yes. Use func_num_args() and func_get_arg() to get the arguments: <?php function dynamic_args() { echo "Number of arguments: " . func_num_args() . "<br />"; for($i = 0 ; $i < func_num_args(); $i++) { echo