Php Obfuscator Online Official

// Step 5: final beautify? just ensure php tags remain. // Ensure that if base64_decode is used heavily, code remains valid. // Add a small comment at top to prevent confusion let finalCode = "<?php /* obfuscated by php-online-tool */ ?>\n" + obfuscated; // If original starts with <?php we replace accordingly, but keep integrity if (obfuscated.trim().startsWith('<?php')) finalCode = obfuscated; else if (obfuscated.trim().startsWith('<?')) finalCode = obfuscated; else finalCode = "<?php\n" + obfuscated + "\n?>"; // Additional: if stripping spaces, collapse excessive spaces again if (optStripSpace.checked) finalCode = finalCode.replace(/\n\s*\n/g, "\n").replace(/ 2,/g, ' '); return finalCode; }

// ---- Helper: generate random name ---- function randName(prefix = '_') const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; let name = prefix; for (let i = 0; i < 6; i++) name += chars[Math.floor(Math.random() * chars.length)]; return name;

// ------------------- CORE OBFUSCATION ENGINE ------------------ // This is a lightweight but powerful obfuscator that respects PHP syntax. // It handles variables, functions, strings, numbers, whitespace. // Note: not a full AST parser but regex + smart token simulation. php obfuscator online

let obfuscated = code; // --- STRIP COMMENTS & WHITESPACE (if option enabled) --- if (optStripSpace.checked) // remove multi-line comments /* ... */ (non greedy) obfuscated = obfuscated.replace(/\/\*[\s\S]*?\*\//g, ''); // remove single line comments // and # (but not inside strings, simplified: we replace only outside contexts but safer approach: remove only if not inside quotes // we apply a safe method: remove // and # that are not part of string literal. For simplicity, we remove comments line by line but avoid destroying http:// // better: remove // and # at start of line or after spaces, but preserve "//" inside strings. For obfuscation tool it's okay edge. // more robust: split lines and remove trailing comments but not perfect. We use regex with negative lookbehind? but multiline. // Simpler but safe enough: replace // and # that are not between quotes? Hard. Use a practical approach: remove all // style comments using pattern. obfuscated = obfuscated.replace(/(?<![\'"])\/\/.*

// Step 1: Extract variable names ($var) inside code (excluding those inside strings and comments already stripped partially) // We'll do a simple regex that finds $[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]* but avoid special cases like ${} // We'll apply variable renaming only for user variables. if (optVarRename.checked) const varRegex = /\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\b/g; let match; // collect all variables const candidates = new Set(); while ((match = varRegex.exec(obfuscated)) !== null) let varName = match[1]; // skip superglobals and common reserved? keep _GET, _POST, etc but user can rename them optionally risky? we skip $this and $GLOBALS if (['this', 'GLOBALS', '_SERVER', '_GET', '_POST', '_REQUEST', '_SESSION', '_COOKIE', '_FILES', '_ENV'].includes(varName)) continue; if (varName.startsWith('_')) continue; // keep some internal? candidates.add(varName); // assign random names for (let v of candidates) if (!varMap.has(v)) varMap.set(v, randName('_v')); // replace variables in code (with word boundaries) for (let [orig, rand] of varMap.entries()) const regex = new RegExp(`\\$$orig\\b`, 'g'); obfuscated = obfuscated.replace(regex, `$$rand`); // Step 5: final beautify

// Step 4: Numeric literal obfuscation: 42 -> (0x2A) or (24+18) etc if (optNumObf.checked) // Replace integer numbers (not inside strings or already obfuscated) obfuscated = obfuscated.replace(/\b(\d+)\b/g, (match, num) => );

@media (max-width: 780px) .container padding: 1rem; .panel padding: 1rem; button padding: 0.5rem 1rem; </style> </head> <body> <div class="container"> <h1>🔐 PHP Obfuscator <span style="font-size:1.8rem;">⚡</span></h1> <div class="sub">Protect your PHP scripts — Rename variables, encode strings, scramble logic (executable output)</div> // Add a small comment at top to

footer text-align: center; margin-top: 2rem; font-size: 0.7rem; color: #4b556b;