![]() |
[PHP] Funktion will nicht so wie ich
Moin,
ich habe folgende funktion geschrieben:
Code:
und das kommt davor:
$_APRON_general_security_mode = "fix"; // READ THE MANUAL BEFORE EDITING THIS!!!
function _APRON_censoring($_APRON_pattern) { if ($_APRON_general_security_mode == "fix") { for ($_APRON_x = 1; $_APRON_x <= strlen($_APRON_pattern); $_APRON_x++) { if ($_APRON_x > 1) { $_APRON_sub = $_APRON_sub."*"; } } return ($_APRON_pattern[1].$_APRON_sub); } if ($_APRON_general_security_mode == "block") { return (""); } } echo _APRON_censoring("test");
Code:
die funktion soll dabei aus test t*** machen. tut sie aber nicht, und ich kann keinen fehler finden :?
$_APRON_general_security_mode = "fix";
|
Re: [PHP] Funktion will nicht so wie ich
Ist zwar etwas unübersichtlich, aber ich glaube, ich weis woron es liegt.
Mach mal aus
Code:
das hier:
if ($_APRON_general_security_mode == "fix") {
Code:
Und schreib, ob es dann geht ...
if (TRUE) {
(Ich vermute stark, dass $_APRON_general_security_mode in der Funktion nicht bekannt ist ...) |
Re: [PHP] Funktion will nicht so wie ich
Hi Meflin, so geht es:
Code:
define(_APRON_general_security_mode, "fix"); // READ THE MANUAL BEFORE EDITING THIS!!!
function _APRON_censoring($_APRON_pattern) { if (_APRON_general_security_mode == "fix") { for ($_APRON_x = 1; $_APRON_x <= strlen($_APRON_pattern); $_APRON_x++) { if ($_APRON_x > 1) { $_APRON_sub = $_APRON_sub."*"; } } return ($_APRON_pattern[0].$_APRON_sub); } if (_APRON_general_security_mode == "block") { return (""); } } echo _APRON_censoring("test"); |
Re: [PHP] Funktion will nicht so wie ich
Hi Meflin,
oder so:
Code:
Greetz
$_APRON_general_security_mode = "fix"; // READ THE MANUAL BEFORE EDITING THIS!!!
function _APRON_censoring($_APRON_pattern) { global $_APRON_general_security_mode; alcaeus |
Re: [PHP] Funktion will nicht so wie ich
Das meinte ich, nur ist mir das "global" nicht mehr eingefallen ...
|
Re: [PHP] Funktion will nicht so wie ich
geht bei mir auch nicht :shock:
und das auch nicht:
Code:
<?
function _APRON_censoring($_APRON_pattern, $_APRON_mode) { if (_APRON_mode == "fix") { for ($_APRON_x = 1; $_APRON_x <= strlen($_APRON_pattern); $_APRON_x++) { if ($_APRON_x > 1) { $_APRON_sub = $_APRON_sub."*"; } } return ($_APRON_pattern[0].$_APRON_sub); } if (_APRON_mode == "block") { return (""); } } echo _APRON_censoring("test","fix"); ?> |
Re: [PHP] Funktion will nicht so wie ich
ich bin dumm, letzteres geht, nur $ vergessen. aber warum kommt da kein fehler :gruebel:
|
Re: [PHP] Funktion will nicht so wie ich
wo ?
|
Re: [PHP] Funktion will nicht so wie ich
oder ganz einfach.
als 1. Zeile in der Funktion dieses einfügen:
Code:
global $_APRON_general_security_mode;
externe Variablen sind "normaler Weise" nicht innerhalb von Funktionen verfügbar.
Code:
function _APRON_censoring($_APRON_pattern) {
global $_APRON_general_security_mode; if ($_APRON_general_security_mode == "fix") { [edit] ach, da hab'sch ja jemanden übersehn, der das schon sagte -.-'' [edit2] @jfheinz Zitat:
|
Re: [PHP] Funktion will nicht so wie ich
Das "wo?" war auf
Zitat:
Nochmal zu dem Code:
Code:
Ich vermute, das PHP das "_APRON_mode" als Konstante verwerten will, jedoch keine findet und somit einen String daraus macht, was zu
if (_APRON_mode == "fix") {
Code:
führt, was logischerweise immer Falsch ist ...
if ("_APRON_mode" == "fix") {
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:49 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz