Php indent problem
What is the problem you’re having? Please provide a detailed explanation so that other’s may understand and try to help you.
so the string containing html causes the problem? does this happen while typing, or while using the Reindent functionality or both? can you paste the code here as text so we can try reproducing this behavior ourselves?
its happening when i use this command
{“keys”: [“alt+shift+f”], “command”: “reindent”, “args”: {“single_line”: false}},
btw my code;
function giris($sorgu){
$query=$this->db->prepare(“SELECT * FROM kullanicilar WHERE email=’”.$sorgu[“email”]."’ and sifre=’".md5(trim($sorgu[“sifre”]))."’ “);
$query->execute();
$result=$query->fetch(PDO::FETCH_ASSOC);
if($query->rowCount()>0){
$_SESSION[“kullanici_bilgileri”]=$result;
$_SESSION[“kullanici_bilgileri”][“ad_soyad”]=$result[“ad”].” “.$result[“soyad”];
$this->swal(“Başarıyla giriş yapıldı”,“success”);
echo "";
}else{
$this->swal(“E-Mail veya Şifre Yanlış!”,“error”);
}
}
it’s kinda fixable by editing the indentation rules for PHP (i.e. using https://packagecontrol.io/packages/PackageResourceViewer) to ensure they apply to strings:
--- Shipped Packages/PHP/Indentation Rules.tmPreferences 2019-01-18 12:17:50
+++ Packages/PHP/Indentation Rules.tmPreferences 2019-11-01 21:13:19
@@ -4,21 +4,21 @@
<key>name</key>
<string>Indentation Rules</string>
<key>scope</key>
- <string>source.php - comment - meta.embedded.html - string, meta.html-newline-after-php</string>
+ <string>source.php - comment - meta.embedded.html, meta.html-newline-after-php</string>
<key>settings</key>
<dict>
but then your whole string will be have the same indentation level except inside the function, so I guess you may want to tweak the regex patterns some:
<?
function giris($sorgu){
$query=$this->db->prepare(“SELECT * FROM kullanicilar WHERE email=’”.$sorgu[“email”]."’ and sifre=’".md5(trim($sorgu[“sifre”]))."’ ");
$query->execute();
$result=$query->fetch(PDO::FETCH_ASSOC);
if($query->rowCount()>0){
$_SESSION[“kullanici_bilgileri”]=$result;
$_SESSION[“kullanici_bilgileri”][“ad_soyad”]=$result[“ad”].” “.$result[“soyad”];
$this->swal(“Başarıyla giriş yapıldı”,“success”);
echo "<script>
setTimeout(function(){
window.location.href
}, 2000);
</script>";
}else{
$this->swal(“E-Mail veya Şifre Yanlış!”,“error”);
}
}
THANKS it worked but same problem on comment strings
Can i do something for this ?
in fact, php indentation in Sublime a little “buggy”
it’s a really bad code, but I work with those kind of a code quite often:)
and I can’t find a good formater for php, maybe someone can suggest some ?
I had try few packages, but they work a little strange(for example some of them save file twice, so ctrl+z not work after formatting, e.t.c). Maybe someone can suggest something,)